Documentation
¶
Index ¶
- Variables
- func RequirePermission(casbinEnforcer *casbin.Enforcer, user *AuthenticatedUser, ...) error
- type AuthConfig
- type AuthMeData
- type AuthenticatedUser
- type Claims
- type LoginRequest
- type LoginResponse
- type LogtoVerifier
- type Service
- func (u *Service) Authenticate(ctx context.Context, tokenString string) (*AuthenticatedUser, error)
- func (u *Service) GetConfig(ctx context.Context) *AuthConfig
- func (u *Service) Login(ctx context.Context, req *LoginRequest) (*LoginResponse, error)
- func (u *Service) LoginWithLogto(ctx context.Context, subject string, email *string) (*LoginResponse, error)
- func (u *Service) Logout(ctx context.Context, tokenString string) error
- func (u *Service) Me(ctx context.Context, tokenString string) (*AuthMeData, error)
- func (u *Service) RequireAdmin(user *AuthenticatedUser) error
- func (u *Service) RequireClient(user *AuthenticatedUser) error
- func (u *Service) VerifyLogtoIDToken(ctx context.Context, idToken string) (*Claims, error)
- func (u *Service) VerifyLogtoToken(ctx context.Context, accessToken string) (*Claims, error)
- type TokenVerifier
- type User
- type UserStore
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUserNotFound = errors.New("user not found")
Functions ¶
func RequirePermission ¶
func RequirePermission(casbinEnforcer *casbin.Enforcer, user *AuthenticatedUser, object, action string) error
Types ¶
type AuthConfig ¶
type AuthMeData ¶
type AuthenticatedUser ¶
type LoginRequest ¶
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
ExpiresAt int64 `json:"expires_at"`
User *AuthMeData `json:"user,omitempty"`
}
type LogtoVerifier ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func ProvideService ¶
func ProvideService( userRepo UserStore, jwtService *authtoken.JWTService, pwdService *authtoken.PasswordService, casbinEnforcer *casbin.Enforcer, cfg config.Config, blacklist *authtoken.BlacklistService, logtoVerifier LogtoVerifier, ) (*Service, error)
func (*Service) Authenticate ¶
func (*Service) Login ¶
func (u *Service) Login(ctx context.Context, req *LoginRequest) (*LoginResponse, error)
func (*Service) LoginWithLogto ¶
func (*Service) RequireAdmin ¶
func (u *Service) RequireAdmin(user *AuthenticatedUser) error
func (*Service) RequireClient ¶
func (u *Service) RequireClient(user *AuthenticatedUser) error
func (*Service) VerifyLogtoIDToken ¶
type TokenVerifier ¶
type UserStore ¶
type UserStore interface {
FindByID(ctx context.Context, id uint64) (*User, error)
FindByUsername(ctx context.Context, username string) (*User, error)
FindByExternalSubject(ctx context.Context, sub string) (*User, error)
Create(ctx context.Context, user *User, passwordHash string) error
UpdatePassword(ctx context.Context, id uint64, hash string) error
UpdateStatus(ctx context.Context, id uint64, status string) error
HasUsers(ctx context.Context) (bool, error)
LinkExternalSubject(ctx context.Context, userID uint64, sub string) error
EnsureDefaultAdmin(ctx context.Context, defaultPWHash string) (uint64, error)
VerifyPassword(ctx context.Context, username, password string) (*User, bool, error)
}
Click to show internal directories.
Click to hide internal directories.