usecase

package
v0.0.0-...-8450a52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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 (*Authorization) FindAndValidateApplication

func (a *Authorization) FindAndValidateApplication(ktx kontext.Context, clientUID, clientSecret *string) (entity.OauthApplication, jsonapi.Errors)

func (*Authorization) Grant

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 (*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 (*Authorization) ImplicitGrant

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
}

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL