Documentation ¶
Index ¶
- type Authorization
- func (a *Authorization) ClientCredential(ktx kontext.Context, accessTokenReq entity.AccessTokenRequestJSON, ...) (entity.OauthAccessToken, *entity.OauthRefreshToken, jsonapi.Errors)
- func (a *Authorization) FindAndValidateApplication(ktx kontext.Context, clientUID, clientSecret *string) (entity.OauthApplication, jsonapi.Errors)
- func (a *Authorization) Grant(ktx kontext.Context, authorizationReq entity.AuthorizationRequestJSON) (entity.OauthAccessGrantJSON, jsonapi.Errors)
- func (a *Authorization) GrantAuthorizationCode(ktx kontext.Context, authorizationReq entity.AuthorizationRequestJSON) (interface{}, jsonapi.Errors)
- func (a *Authorization) GrantRefreshToken(ktx kontext.Context, oauthAccessToken entity.OauthAccessToken, ...) (entity.OauthRefreshToken, jsonapi.Errors)
- func (a *Authorization) GrantToken(ktx kontext.Context, accessTokenReq entity.AccessTokenRequestJSON) (entity.OauthAccessTokenJSON, jsonapi.Errors)
- func (a *Authorization) GrantTokenFromAuthorizationCode(ktx kontext.Context, accessTokenReq entity.AccessTokenRequestJSON, ...) (entity.OauthAccessToken, *entity.OauthRefreshToken, string, jsonapi.Errors)
- func (a *Authorization) GrantTokenFromRefreshToken(ktx kontext.Context, accessTokenReq entity.AccessTokenRequestJSON) (entity.OauthAccessToken, entity.OauthRefreshToken, jsonapi.Errors)
- func (a *Authorization) ImplicitGrant(ktx kontext.Context, authorizationReq entity.AuthorizationRequestJSON) (entity.OauthAccessTokenJSON, jsonapi.Errors)
- func (a *Authorization) RevokeToken(ktx kontext.Context, revokeAccessTokenReq entity.RevokeAccessTokenRequestJSON) jsonapi.Errors
- func (a *Authorization) ValidateAuthorizationGrant(ktx kontext.Context, r entity.AuthorizationRequestJSON, ...) jsonapi.Errors
- func (a *Authorization) ValidateTokenAuthorizationCode(ktx kontext.Context, r entity.AccessTokenRequestJSON, ...) exception.Exception
- func (a *Authorization) ValidateTokenGrant(r entity.AccessTokenRequestJSON) jsonapi.Errors
- type Formatter
- type OauthAccessGrantRepository
- type OauthAccessTokenRepository
- type OauthApplicationRepository
- type OauthRefreshTokenRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorization ¶
type Authorization struct {
// contains filtered or unexported fields
}
Authorization struct handle all of things related to oauth2 authorization
func NewAuthorization ¶
func NewAuthorization( oauthApplicationRepo OauthApplicationRepository, oauthAccessTokenRepo OauthAccessTokenRepository, oauthAccessGrantRepo OauthAccessGrantRepository, oauthRefreshTokenRepo OauthRefreshTokenRepository, formatter Formatter, config entity.OauthPlugin, sqldb db.DB, apiError module.ApiError, ) *Authorization
func (*Authorization) ClientCredential ¶
func (a *Authorization) ClientCredential(ktx kontext.Context, accessTokenReq entity.AccessTokenRequestJSON, oauthApplication entity.OauthApplication) (entity.OauthAccessToken, *entity.OauthRefreshToken, jsonapi.Errors)
func (*Authorization) FindAndValidateApplication ¶
func (a *Authorization) FindAndValidateApplication(ktx kontext.Context, clientUID, clientSecret *string) (entity.OauthApplication, jsonapi.Errors)
func (*Authorization) Grant ¶
func (a *Authorization) Grant(ktx kontext.Context, authorizationReq entity.AuthorizationRequestJSON) (entity.OauthAccessGrantJSON, jsonapi.Errors)
Grant authorization an access code
func (*Authorization) GrantAuthorizationCode ¶
func (a *Authorization) GrantAuthorizationCode(ktx kontext.Context, authorizationReq entity.AuthorizationRequestJSON) (interface{}, jsonapi.Errors)
func (*Authorization) GrantRefreshToken ¶
func (a *Authorization) GrantRefreshToken(ktx kontext.Context, oauthAccessToken entity.OauthAccessToken, oauthApplication entity.OauthApplication, tx db.TX) (entity.OauthRefreshToken, jsonapi.Errors)
func (*Authorization) GrantToken ¶
func (a *Authorization) GrantToken(ktx kontext.Context, accessTokenReq entity.AccessTokenRequestJSON) (entity.OauthAccessTokenJSON, jsonapi.Errors)
func (*Authorization) GrantTokenFromAuthorizationCode ¶
func (a *Authorization) GrantTokenFromAuthorizationCode(ktx kontext.Context, accessTokenReq entity.AccessTokenRequestJSON, oauthApplication entity.OauthApplication) (entity.OauthAccessToken, *entity.OauthRefreshToken, string, jsonapi.Errors)
func (*Authorization) GrantTokenFromRefreshToken ¶
func (a *Authorization) GrantTokenFromRefreshToken(ktx kontext.Context, accessTokenReq entity.AccessTokenRequestJSON) (entity.OauthAccessToken, entity.OauthRefreshToken, jsonapi.Errors)
func (*Authorization) ImplicitGrant ¶
func (a *Authorization) ImplicitGrant(ktx kontext.Context, authorizationReq entity.AuthorizationRequestJSON) (entity.OauthAccessTokenJSON, jsonapi.Errors)
ImplicitGrant implementation refer to this RFC 6749 Section 4.2 https://www.rfc-editor.org/rfc/rfc6749#section-4.2 In altair we implement only confidential oauth application that can request implicit grant
func (*Authorization) RevokeToken ¶
func (a *Authorization) RevokeToken(ktx kontext.Context, revokeAccessTokenReq entity.RevokeAccessTokenRequestJSON) jsonapi.Errors
RevokeToken revoke given access token request
func (*Authorization) ValidateAuthorizationGrant ¶
func (a *Authorization) ValidateAuthorizationGrant(ktx kontext.Context, r entity.AuthorizationRequestJSON, application entity.OauthApplication) jsonapi.Errors
func (*Authorization) ValidateTokenAuthorizationCode ¶
func (a *Authorization) ValidateTokenAuthorizationCode(ktx kontext.Context, r entity.AccessTokenRequestJSON, data entity.OauthAccessGrant) exception.Exception
func (*Authorization) ValidateTokenGrant ¶
func (a *Authorization) ValidateTokenGrant(r entity.AccessTokenRequestJSON) jsonapi.Errors
type Formatter ¶
type Formatter interface { AccessTokenFromAuthorizationRequestInsertable(r entity.AuthorizationRequestJSON, application entity.OauthApplication) entity.OauthAccessTokenInsertable AccessTokenFromOauthAccessGrantInsertable(oauthAccessGrant entity.OauthAccessGrant, application entity.OauthApplication) entity.OauthAccessTokenInsertable AccessGrantFromAuthorizationRequestInsertable(r entity.AuthorizationRequestJSON, application entity.OauthApplication) entity.OauthAccessGrantInsertable AccessTokenClientCredentialInsertable(application entity.OauthApplication, scope *string) entity.OauthAccessTokenInsertable OauthApplicationInsertable(r entity.OauthApplicationJSON) entity.OauthApplicationInsertable AccessTokenFromOauthRefreshTokenInsertable(application entity.OauthApplication, accessToken entity.OauthAccessToken) entity.OauthAccessTokenInsertable RefreshTokenInsertable(application entity.OauthApplication, accessToken entity.OauthAccessToken) entity.OauthRefreshTokenInsertable AccessGrant(e entity.OauthAccessGrant) entity.OauthAccessGrantJSON AccessToken(e entity.OauthAccessToken, redirectURI string, refreshTokenJSON *entity.OauthRefreshTokenJSON) entity.OauthAccessTokenJSON RefreshToken(e entity.OauthRefreshToken) entity.OauthRefreshTokenJSON }
type OauthAccessGrantRepository ¶
type OauthAccessGrantRepository interface { One(ktx kontext.Context, ID int, tx db.TX) (entity.OauthAccessGrant, exception.Exception) OneByCode(ktx kontext.Context, code string, tx db.TX) (entity.OauthAccessGrant, exception.Exception) Create(ktx kontext.Context, data entity.OauthAccessGrantInsertable, tx db.TX) (int, exception.Exception) Revoke(ktx kontext.Context, code string, tx db.TX) exception.Exception }
type OauthAccessTokenRepository ¶
type OauthAccessTokenRepository interface { OneByToken(ktx kontext.Context, token string, tx db.TX) (entity.OauthAccessToken, exception.Exception) One(ktx kontext.Context, ID int, tx db.TX) (entity.OauthAccessToken, exception.Exception) Create(ktx kontext.Context, data entity.OauthAccessTokenInsertable, tx db.TX) (int, exception.Exception) Revoke(ktx kontext.Context, token string, tx db.TX) exception.Exception }
type OauthApplicationRepository ¶
type OauthApplicationRepository interface { Paginate(ktx kontext.Context, offset, limit int, tx db.TX) ([]entity.OauthApplication, exception.Exception) Count(ktx kontext.Context, tx db.TX) (int, exception.Exception) One(ktx kontext.Context, ID int, tx db.TX) (entity.OauthApplication, exception.Exception) OneByUIDandSecret(ktx kontext.Context, clientUID, clientSecret string, tx db.TX) (entity.OauthApplication, exception.Exception) Create(ktx kontext.Context, data entity.OauthApplicationInsertable, tx db.TX) (int, exception.Exception) Update(ktx kontext.Context, ID int, data entity.OauthApplicationUpdateable, tx db.TX) exception.Exception }
type OauthRefreshTokenRepository ¶
type OauthRefreshTokenRepository interface { OneByToken(ktx kontext.Context, token string, tx db.TX) (entity.OauthRefreshToken, exception.Exception) One(ktx kontext.Context, ID int, tx db.TX) (entity.OauthRefreshToken, exception.Exception) Create(ktx kontext.Context, data entity.OauthRefreshTokenInsertable, tx db.TX) (int, exception.Exception) Revoke(ktx kontext.Context, token string, tx db.TX) exception.Exception }
Source Files ¶
- authorization.go
- client_credential.go
- exception_mapping.go
- find_and_validate_application.go
- grant.go
- grant_authorization_code.go
- grant_refresh_token.go
- grant_token.go
- grant_token_from_authorization_code.go
- grant_token_from_refresh_token.go
- implicit_grant.go
- revoke_token.go
- validate_authorization_grant.go
- validate_token_authorization_code.go
- validate_token_grant.go
Click to show internal directories.
Click to hide internal directories.