You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
909 B
Go
40 lines
909 B
Go
package auth
|
|
|
|
import "github.com/gofiber/fiber/v2"
|
|
|
|
// HTTP headers
|
|
const (
|
|
AuthorizationHeader = "Authorization"
|
|
BearerPrefix = "Bearer "
|
|
)
|
|
|
|
// Context keys for storing user information in fiber context
|
|
const (
|
|
UserIDKey = "user_id"
|
|
UsernameKey = "username"
|
|
EmailKey = "email"
|
|
RolesKey = "roles"
|
|
)
|
|
|
|
// Common role names
|
|
const (
|
|
AdminRole = "admin"
|
|
PlayerRole = "player"
|
|
)
|
|
|
|
// Error messages
|
|
const (
|
|
ErrUserNotAuthenticated = "user not authenticated"
|
|
ErrAuthHeaderRequired = "authorization header required"
|
|
ErrInvalidAuthHeaderFormat = "invalid authorization header format"
|
|
ErrInvalidToken = "invalid token"
|
|
ErrNoRolesFound = "no roles found in token"
|
|
ErrInsufficientPermissions = "insufficient permissions"
|
|
)
|
|
|
|
// HTTP status codes for auth errors
|
|
const (
|
|
StatusUnauthorized = fiber.StatusUnauthorized
|
|
StatusForbidden = fiber.StatusForbidden
|
|
)
|