Documentation
¶
Overview ¶
Package gate is an authentication and authorization library with a RBAC implementation for Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrForbidden is thrown when an user is forbidden to take an action on an object ErrForbidden = errors.New("forbidden") // ErrNoAbilities is thrown when an user has no abilities ErrNoAbilities = errors.New("there is no abilities") )
Functions ¶
Types ¶
type Auth ¶
type Auth interface { UserService() (UserService, error) RoleService() (RoleService, error) TokenService() (TokenService, error) JWTService() (*JWTService, error) Matcher() (internal.Matcher, error) Login(map[string]string) (User, error) LoginURL(string) (string, error) IssueJWT(User) (JWT, error) ParseJWT(string) (JWT, error) StoreJWT(JWT) error Authenticate(string) (User, error) Authorize(User, string, string) error GetUserFromJWT(JWT) (User, error) GetUserAbilities(User) ([]UserAbility, error) }
Auth is the common interface for authentication and authorization. E.g. PasswordBased, OAuth, etc.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is the configuration for Auth
func NewConfig ¶
func NewConfig(jwtSigningKey, jwtVerifyingKey interface{}, jwtExpiration time.Duration, jwtSkipClaimsValidation bool) Config
NewConfig is the constructor for Config
func (Config) JWTExpiration ¶
JWTExpiration is the setter for JWT expiration configuration
func (Config) JWTSigningKey ¶
func (config Config) JWTSigningKey() interface{}
JWTSigningKey is the setter for JWT signing key configuration
func (Config) JWTSkipClaimsValidation ¶
JWTSkipClaimsValidation is the setter for JWT claims validation skip configuration
func (Config) JWTVerifyingKey ¶
func (config Config) JWTVerifyingKey() interface{}
JWTVerifyingKey is the setter for JWT verifying key configuration
type HasEmail ¶
type HasEmail interface {
GetEmail() string
}
HasEmail is the contract for user service entity
type JWTClaims ¶
type JWTClaims struct { User UserInfo `json:"user"` jwt.StandardClaims }
JWTClaims are JWT claims with user's information
type JWTConfig ¶
type JWTConfig struct {
// contains filtered or unexported fields
}
JWTConfig is the configuration for JWT service
type JWTService ¶
type JWTService struct { Now func() time.Time GenerateClaimsID func() string // contains filtered or unexported fields }
JWTService is the service which manages JWTs
func NewJWTService ¶
func NewJWTService(config JWTConfig) *JWTService
NewJWTService is the constructor for JWTService
func (JWTService) Issue ¶
func (service JWTService) Issue(claims JWTClaims) (token JWT, err error)
Issue generates a token from JWT claims with the service configuration
func (JWTService) NewClaims ¶
func (service JWTService) NewClaims(user User) JWTClaims
NewClaims generates JWTClaims for a specific user
func (JWTService) NewTokenFromClaims ¶
func (service JWTService) NewTokenFromClaims(claims JWTClaims) (token JWT)
NewTokenFromClaims constructs a token from JWT claims
type Role ¶
type Role interface {
GetAbilities() []UserAbility
}
Role is the contract for the role entity
type RoleService ¶
RoleService is the contract which offers queries on the role entity
type TokenService ¶
TokenService is the contract which offers queries on the token entity
type UserAbility ¶
UserAbility is the contract for the ability entity
Directories
¶
Path | Synopsis |
---|---|
Package dependency contains services and their container to eliminate unnecessary duplication from auth drivers
|
Package dependency contains services and their container to eliminate unnecessary duplication from auth drivers |
Package internal contains support packages for github.com/hiendv/gate
|
Package internal contains support packages for github.com/hiendv/gate |
test/fixtures
Package fixtures provide testing fixtures
|
Package fixtures provide testing fixtures |
Package oauth is the OAuth2 authentication driver for github.com/hiendv/gate.
|
Package oauth is the OAuth2 authentication driver for github.com/hiendv/gate. |
Package password is the password-based authentication driver for github.com/hiendv/gate
|
Package password is the password-based authentication driver for github.com/hiendv/gate |