Documentation
¶
Index ¶
- Constants
- func BuildPurposeScope(label string) string
- func GetPurpose(scope string) string
- func GetSignedToken(ac *AccessClaims) (string, error)
- func IsAllowedScope(candidate string) bool
- func IsMisadminScope(candidate string) bool
- func IsPurposeScope(candidate string) bool
- func IsRoleScope(candidate string) bool
- func SetAccessClaimsJWT(ctx context.Context, jwt string) context.Context
- func SetAccesses(ctx context.Context, acc *AccessClaims) context.Context
- func TrimPurposes(scopes []string) []string
- type ACRSecLvl
- type AccessClaims
- func (c *AccessClaims) ACRIsGTE(secLvl ACRSecLvl) error
- func (c *AccessClaims) GetAdminAppID() *string
- func (c *AccessClaims) GetDPOAppID() *string
- func (c *AccessClaims) IsAdminOn(appID string) bool
- func (c *AccessClaims) IsAnyAdmin() bool
- func (c *AccessClaims) IsAnyApp() bool
- func (c *AccessClaims) IsAnyDPO() bool
- func (c *AccessClaims) IsAnyService() bool
- func (c *AccessClaims) IsAnyUser() bool
- func (c *AccessClaims) IsApp(appID string) bool
- func (c *AccessClaims) IsDPOOn(appID string) bool
- func (c *AccessClaims) IsMisadmin() bool
- func (c *AccessClaims) IsNotAdmin() bool
- func (c *AccessClaims) IsNotAdminOn(appID string) bool
- func (c *AccessClaims) IsNotAnyApp() bool
- func (c *AccessClaims) IsNotAnyService() bool
- func (c *AccessClaims) IsNotAnyUser() bool
- func (c *AccessClaims) IsNotApp(appID string) bool
- func (c *AccessClaims) IsNotDPO() bool
- func (c *AccessClaims) IsNotDPOOn(appID string) bool
- func (c *AccessClaims) IsNotMisadmin() bool
- func (c *AccessClaims) IsNotService(serviceID string) bool
- func (c *AccessClaims) IsNotUser(userID string) bool
- func (c *AccessClaims) IsService(serviceID string) bool
- func (c *AccessClaims) IsUser(userID string) bool
- func (c *AccessClaims) SetRawJWT(jwt string)
- func (c *AccessClaims) Valid() error
- func (c *AccessClaims) ValidAudience(expected string) error
- type AppRole
Constants ¶
const JWTStaticSignature = "wedontmindaboutsigningfornow"
JWTStaticSignature is the key used to sign JWT internally, we don't mind having a secret one for now since the jwt goes only inside our internal & private network
Variables ¶
This section is empty.
Functions ¶
func BuildPurposeScope ¶
BuildPurposeScope takes a purpose label and return a purpose scope
func GetPurpose ¶
GetPurpose takes a purpose scope and return the application purpose IDs contained inside Warning: GetPurpose is not meant to receive anything else than a purpose scope there is no error handling about getting an invalid purpose scope
func GetSignedToken ¶
func GetSignedToken(ac *AccessClaims) (string, error)
GetSignedToken transforms an AccessClaims structure into a JWT
func IsAllowedScope ¶
IsAllowedScope return true if given candidate string is considered as an allowed scope A scope can be: - openid scope - caller type scope: user|service|application - misadmin scope - role scope - purpose scope
func IsMisadminScope ¶
IsMisadminScope return true if given scope string is considered as a misadmin scope.
func IsPurposeScope ¶
IsPurposeScope return true if given candidate string is considered as a purpose scope.
func IsRoleScope ¶
IsRoleScope return true if given candidate string is considered as a role scope. Forbidden usage of * in role scopes.
func SetAccessClaimsJWT ¶
SetAccessClaimsJWT override current in-context access claims JWT value
func SetAccesses ¶
func SetAccesses(ctx context.Context, acc *AccessClaims) context.Context
SetAccesses returns ctx with AccessClaims set inside it using accessContextKey
func TrimPurposes ¶
TrimPurposes removes application purpose scopes from given list of scopes and return it It does not modify scope directly but return scopes after the trim as a slice of strings
Types ¶
type ACRSecLvl ¶
type ACRSecLvl string
Security Level - Authentication Context Class Reference (a.k.a. ACR values) Corresponding to a level of certainty, while the token has been generated, of the identity of the token requester The higher the security level is, stronger is the possibility the subject claims correspond in reality to the person who generated an access token
type AccessClaims ¶
type AccessClaims struct {
Issuer string `json:"iss"` // Service which distributed the token
Audiences []string `json:"aud"` // Audiences which should answer to the tooken
ClientID string `json:"cli"` // SSO client ID which generated the token
ExpiresAt int64 `json:"exp"` // Expiry time
IssuedAt int64 `json:"iat"` // Issuing time
NotBefore int64 `json:"nbf"` // Time before use
Subject string `json:"sub"` // Subject (owner) bound to the token
Scope string `json:"sco"` // Scope beared by the token
ACR ACRSecLvl `json:"acr"` // Authentication Class Reference
Token string `json:"tok"` // Raw Access Token
IdentityID string `json:"mid"` // Misakey ID - Identity bound to the token
AccountID null.String `json:"aid"` // Account (nullable) bound to the token
JWT string `json:"-"` // Raw JWT Token
}
Claims declared to format our Access JWTs Implement https://godoc.org/github.com/dgrijalva/jwt-go#Claims interface
func GetAccesses ¶
func GetAccesses(ctx context.Context) *AccessClaims
GetAccesses returns AccessClaims found inside current context using defined accessContextKey It return a nil pointer if no claims have been found
func (*AccessClaims) ACRIsGTE ¶
func (c *AccessClaims) ACRIsGTE(secLvl ACRSecLvl) error
ACRIsGTE compares AccessClaims ACR (Authentication Context Class - Sec Level) with the secLvl parameter It uses kind of >= operator principle and return an error if the current ACR is stricty inferior to asked one
func (*AccessClaims) GetAdminAppID ¶
func (c *AccessClaims) GetAdminAppID() *string
GetAdminAppID return application on which the user is Admin on if not found, nil is returned
func (*AccessClaims) GetDPOAppID ¶
func (c *AccessClaims) GetDPOAppID() *string
GetDPOAppID return application on which the user is DPO on if not found, nil is returned
func (*AccessClaims) IsAdminOn ¶ added in v1.7.0
func (c *AccessClaims) IsAdminOn(appID string) bool
func (*AccessClaims) IsAnyAdmin ¶ added in v1.3.0
func (c *AccessClaims) IsAnyAdmin() bool
func (*AccessClaims) IsAnyApp ¶
func (c *AccessClaims) IsAnyApp() bool
IsAnyApp returns false if claims' scopes defines an application
func (*AccessClaims) IsAnyDPO ¶ added in v1.3.0
func (c *AccessClaims) IsAnyDPO() bool
func (*AccessClaims) IsAnyService ¶
func (c *AccessClaims) IsAnyService() bool
IsAnyService returns true if claims' scopes defines a service
func (*AccessClaims) IsAnyUser ¶
func (c *AccessClaims) IsAnyUser() bool
IsAnyUser returns true if claims' scopes defines a user
func (*AccessClaims) IsApp ¶ added in v1.7.0
func (c *AccessClaims) IsApp(appID string) bool
IsApp returns true if claims' scopes defines an application and its subject match given app ID
func (*AccessClaims) IsDPOOn ¶ added in v1.7.0
func (c *AccessClaims) IsDPOOn(appID string) bool
func (*AccessClaims) IsMisadmin ¶ added in v1.7.0
func (c *AccessClaims) IsMisadmin() bool
IsMisadmin returns true if claims' scopes defines a user & a misadmin
func (*AccessClaims) IsNotAdmin ¶ added in v1.3.0
func (c *AccessClaims) IsNotAdmin() bool
func (*AccessClaims) IsNotAdminOn ¶
func (c *AccessClaims) IsNotAdminOn(appID string) bool
func (*AccessClaims) IsNotAnyApp ¶
func (c *AccessClaims) IsNotAnyApp() bool
IsNotAnyApp returns false if claims' scopes defines an application
func (*AccessClaims) IsNotAnyService ¶
func (c *AccessClaims) IsNotAnyService() bool
IsNotAnyService returns false if claims' scopes defines a service
func (*AccessClaims) IsNotAnyUser ¶
func (c *AccessClaims) IsNotAnyUser() bool
IsAnyUser returns false if claims' scopes defines a user
func (*AccessClaims) IsNotApp ¶
func (c *AccessClaims) IsNotApp(appID string) bool
IsNotApp returns false if claims' scopes defines an application and its subject match given app ID
func (*AccessClaims) IsNotDPO ¶
func (c *AccessClaims) IsNotDPO() bool
func (*AccessClaims) IsNotDPOOn ¶
func (c *AccessClaims) IsNotDPOOn(appID string) bool
func (*AccessClaims) IsNotMisadmin ¶
func (c *AccessClaims) IsNotMisadmin() bool
IsNotMisadmin returns false if claims' scopes defines a user & a misadmin
func (*AccessClaims) IsNotService ¶
func (c *AccessClaims) IsNotService(serviceID string) bool
IsNotService returns false if claims' scopes defines a service and its subject match given service ID
func (*AccessClaims) IsNotUser ¶
func (c *AccessClaims) IsNotUser(userID string) bool
IsNotUser returns false if claims' scopes defines a user and its subject match given user ID
func (*AccessClaims) IsService ¶ added in v1.7.0
func (c *AccessClaims) IsService(serviceID string) bool
IsService returns true if claims' scopes defines a service and its subject match given service ID
func (*AccessClaims) IsUser ¶ added in v1.7.0
func (c *AccessClaims) IsUser(userID string) bool
IsUser returns true if claims' scopes defines a user and its subject match given user ID
func (*AccessClaims) SetRawJWT ¶
func (c *AccessClaims) SetRawJWT(jwt string)
setRawJWT set the raw jwt corresponding to the access claims
func (*AccessClaims) Valid ¶
func (c *AccessClaims) Valid() error
Valid : all required validation are today done on hydra side
func (*AccessClaims) ValidAudience ¶
func (c *AccessClaims) ValidAudience(expected string) error
ValidAudience : check if the client is part of the audience