Documentation ¶
Index ¶
- Constants
- type ClaimRole
- type Client
- type ClientInformation
- type Config
- type DefaultClient
- func (client *DefaultClient) ClientToken() (string, error)
- func (client *DefaultClient) ClientTokenGrant(opts ...Option) (token string, ttl *time.Duration, err error)
- func (client *DefaultClient) GetClientInformation(clientID string) (*ClientInformation, error)
- func (client *DefaultClient) GetKeys() (keys map[string]*rsa.PublicKey, err error)
- func (client *DefaultClient) GetRolePermissions(roleID string) (perms []Permission, err error)
- func (client *DefaultClient) ValidateAccessToken(accessToken string) (bool, error)
- func (client *DefaultClient) ValidateAndParseClaims(accessToken string) (*JWTClaims, error)
- func (client *DefaultClient) ValidatePermission(claims *JWTClaims, requiredPermission Permission, ...) (bool, error)
- type HTTPClient
- type JWK
- type JWTClaims
- type Keys
- type Option
- type Options
- type Permission
- type Role
- type TokenResponse
Constants ¶
View Source
const ( ActionCreate = 1 ActionRead = 1 << 1 ActionUpdate = 1 << 2 ActionDelete = 1 << 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { ClientToken() (string, error) ValidateAccessToken(accessToken string) (bool, error) ValidateAndParseClaims(accessToken string) (*JWTClaims, error) // ValidatePermission validates if an access token has right for a specific permission // requiredPermission: permission to access resource, example: // {Resource: "ORG:{organizationId}:USER:{userId}:PROJ:{projectId}", Action: 2} // permissionResources: resource string to replace the `{}` placeholder in `requiredPermission` ValidatePermission(claims *JWTClaims, requiredPermission Permission, permissionResources map[string]string) (bool, error) GetRolePermissions(roleID string) (perms []Permission, err error) GetClientInformation(clientID string) (*ClientInformation, error) }
type ClientInformation ¶
type DefaultClient ¶
type DefaultClient struct {
// contains filtered or unexported fields
}
DefaultClient define oauth client config
func NewDefaultClient ¶
func NewDefaultClient(config *Config) *DefaultClient
func (*DefaultClient) ClientToken ¶
func (client *DefaultClient) ClientToken() (string, error)
func (*DefaultClient) ClientTokenGrant ¶
func (*DefaultClient) GetClientInformation ¶
func (client *DefaultClient) GetClientInformation(clientID string) (*ClientInformation, error)
func (*DefaultClient) GetKeys ¶
func (client *DefaultClient) GetKeys() (keys map[string]*rsa.PublicKey, err error)
func (*DefaultClient) GetRolePermissions ¶
func (client *DefaultClient) GetRolePermissions(roleID string) (perms []Permission, err error)
func (*DefaultClient) ValidateAccessToken ¶
func (client *DefaultClient) ValidateAccessToken(accessToken string) (bool, error)
func (*DefaultClient) ValidateAndParseClaims ¶
func (client *DefaultClient) ValidateAndParseClaims(accessToken string) (*JWTClaims, error)
func (*DefaultClient) ValidatePermission ¶
func (client *DefaultClient) ValidatePermission(claims *JWTClaims, requiredPermission Permission, permissionResources map[string]string) (bool, error)
type JWK ¶
type JWK struct { Kty string `json:"kty"` Use string `json:"use"` Kid string `json:"kid"` N string `json:"n"` E string `json:"e"` }
JWK contains json web key's data
type JWTClaims ¶
type JWTClaims struct { OrganizationID string `json:"organizationId"` DisplayName string `json:"display_name"` Roles []ClaimRole `json:"roles"` Scope string `json:"scope"` ClientID string `json:"client_id"` Permissions []Permission `json:"permissions"` jwt.Claims }
JWTClaims holds data stored in a JWT access token with additional Justice Flags field
type Permission ¶
type Role ¶
type Role struct { RoleID string `json:"roleId"` Permissions []Permission `json:"permissions"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.