Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func HashPassword ¶
func VerifyPassword ¶
Types ¶
type AuthRequest ¶
type AuthService ¶
type AuthService interface {
Authenticate(ctx context.Context, req AuthRequest) (interface{}, error)
ValidateToken(ctx context.Context, token string) (*Claims, error)
RefreshToken(ctx context.Context, refreshToken string) (*WebAuthResponse, error)
RevokeToken(ctx context.Context, token string) error
GetPermissions(ctx context.Context, subject string) ([]models.Permission, error)
HasPermission(ctx context.Context, subject string, perm models.Permission) bool
}
func NewAuthService ¶
func NewAuthService( repo repository.Repository, permManager *permissions.PermissionManager, signKey *rsa.PrivateKey, verifyKey *rsa.PublicKey, cfg *models.Config, ) AuthService
type Claims ¶
type Claims struct {
// STANDARD CLAIM
Subject string `json:"sub"`
Audience string `json:"aud"`
ExpiresAt *jwt.NumericDate `json:"exp"`
IssuedAt *jwt.NumericDate `json:"iat"`
NotBefore *jwt.NumericDate `json:"nbf,omitempty"`
Issuer string `json:"iss"`
JwtID string `json:"jti,omitempty"`
AllowReissue bool `json:"allow_reissue,omitempty"`
// REGISTRY CLAIM
Access []models.ResourceActions `json:"access"`
}
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware(auth AuthService, cfg *models.Config, log *logging.LogService) *Middleware
func (*Middleware) AuthMiddleware ¶
func (m *Middleware) AuthMiddleware(next http.Handler) http.Handler
WEB UI AUTH
func (*Middleware) RegistryAuthMiddleware ¶
func (m *Middleware) RegistryAuthMiddleware(next http.Handler) http.Handler
REGISTRY AUTH MIDDLEWARE
type RegAuthResponse ¶
type TokenManager ¶
type TokenManager struct {
// contains filtered or unexported fields
}
func NewTokenManager ¶
func NewTokenManager(signKey *rsa.PrivateKey, verifyKey *rsa.PublicKey) *TokenManager
func (*TokenManager) GenerateToken ¶
func (tm *TokenManager) GenerateToken(claims *Claims) (string, error)
func (*TokenManager) RevokeToken ¶
func (tm *TokenManager) RevokeToken(token string) error
func (*TokenManager) ValidateToken ¶
func (tm *TokenManager) ValidateToken(tokenString string) (*Claims, error)
Click to show internal directories.
Click to hide internal directories.