Documentation
¶
Index ¶
- Constants
- func CreateAuthorization(ctx context.Context, auth *Authorization) error
- func GetSecureJWTMiddleware(realm, secretKey string) (*jwt.GinJWTMiddleware, error)
- func GetToken(ctx context.Context, clientID, authType string) (string, error)
- func IdentityHandler(c *gin.Context) interface{}
- func PayloadMappingHandler(data interface{}) jwt.MapClaims
- func ScopeAuthorizationHandler(data interface{}, c *gin.Context) bool
- type Authorization
- type Client
Constants ¶
View Source
const ( // DatastoreAuthorizations collection AUTHORIZATION DatastoreAuthorizations string = "AUTHORIZATIONS" // AuthTypeJWT constant jwt AuthTypeJWT = "jwt" // AuthTypeSlack constant salack AuthTypeSlack = "slack" )
Variables ¶
This section is empty.
Functions ¶
func CreateAuthorization ¶ added in v0.0.4
func CreateAuthorization(ctx context.Context, auth *Authorization) error
CreateAuthorization creates all data needed for the OAuth fu
func GetSecureJWTMiddleware ¶
func GetSecureJWTMiddleware(realm, secretKey string) (*jwt.GinJWTMiddleware, error)
GetSecureJWTMiddleware instantiates a JWT middleware and all the necessary handlers
func IdentityHandler ¶
IdentityHandler returns the Client structure
func PayloadMappingHandler ¶
PayloadMappingHandler extracts the client_id, user_id and scope of the request
func ScopeAuthorizationHandler ¶
ScopeAuthorizationHandler checks for required scopes
Types ¶
type Authorization ¶
type Authorization struct {
ClientID string `json:"client_id" binding:"required"` // UNIQUE
Name string `json:"name"` // name of the domain, realm, tennant etc
Token string `json:"token" binding:"required"`
TokenType string `json:"token_type" binding:"required"` // user,app,bot
UserID string `json:"user_id"` // depends on TokenType. UserID could equal ClientID or BotUSerID in Slack
Scope string `json:"scope"` // a comma separated list of scopes, see below
Expires int64 `json:"expires"` // 0 = never
// internal
AuthType string `json:"-"` // currently: jwt, slack
Created int64 `json:"-"`
Updated int64 `json:"-"`
}
Authorization represents a user, app or bot and its permissions
func GetAuthorization ¶ added in v0.0.4
func GetAuthorization(ctx context.Context, clientID, authType string) (*Authorization, error)
GetAuthorization looks for an authorization
Click to show internal directories.
Click to hide internal directories.