-
Notifications
You must be signed in to change notification settings - Fork 0
Guide Security
GitHub Actions edited this page Jan 25, 2026
·
2 revisions
Lerne, wie du Security in VelinScript implementierst.
Der @Auth Decorator erfordert Authentifizierung:
@Auth
@GET("/api/profile")
fn getProfile(): User {
return currentUser();
}
Nur authentifizierte Benutzer können diesen Endpoint aufrufen.
Der @Role Decorator erfordert eine bestimmte Rolle:
@Auth
@Role("admin")
@GET("/api/admin/users")
fn getAdminUsers(): List<User> {
return db.findAll(User);
}
Nur Benutzer mit der Rolle "admin" können diesen Endpoint aufrufen.
@Auth
@Role("user")
@GET("/api/users/:id")
fn getUser(id: string): User {
// Nur authentifizierte Benutzer mit Rolle "user"
return db.find(User, id);
}
@Auth
@Role("admin")
@GET("/api/admin/stats")
fn getAdminStats(): Stats {
// Nur authentifizierte Benutzer mit Rolle "admin"
return calculateStats();
}
Endpoints ohne @Auth sind öffentlich:
@GET("/api/public/info")
fn getPublicInfo(): string {
return "Public information";
}
- Immer @Auth verwenden für geschützte Endpoints
- Minimale Rechte - Nur notwendige Rollen erfordern
- Input Validation - Alle Inputs validieren
- Error Handling - Keine sensiblen Informationen in Fehlermeldungen
struct User {
id: string,
name: string,
email: string,
role: string,
}
// Public Endpoint
@GET("/api/public/health")
fn healthCheck(): string {
return "OK";
}
// Authenticated Endpoint
@Auth
@GET("/api/profile")
fn getProfile(): User {
return currentUser();
}
// User Role Required
@Auth
@Role("user")
@GET("/api/users/:id")
fn getUser(id: string): User {
return db.find(User, id);
}
// Admin Role Required
@Auth
@Role("admin")
@GET("/api/admin/users")
fn getAdminUsers(): List<User> {
return db.findAll(User);
}
@Auth
@Role("admin")
@DELETE("/api/admin/users/:id")
fn deleteUser(id: string): void {
db.delete(User, id);
}
- Tutorial 4: Database - Database Integration
- Compiler Architecture
- Pass-Verlauf
- Type Inference
- Code Ordering
- IR Representation
- Borrow Checker
- Code Generation
- Multi-Target Compilation
- Module Resolution
- Framework Integration
- Parallelization
- AI Compiler Passes
- Prompt Optimizer
- System Generation
- Basics
- APIs
- Security
- Database
- Validation
- Authentication
- ML/LLM
- Intelligence Features
- Type Inference
- ML Training
- Pattern Matching
- Closures
- Collections
- HTTP Client
- String Interpolation
- Debugger
- Vektor-Datenbanken
- CLI Reference
- API Keys Setup
- Advanced
- Backend
- Security Best Practices
- AI/ML
- Auto Imports
- Plugin Development