manager

package
v0.0.0-...-d125d34 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CutPostNum = 8
	MustPrefix = "*****"
)

musk the secrets

View Source
const BasicOauthClientLength = 20
View Source
const HorizonAPPClientIDPrefix = "ho_"
View Source
const OauthClientSecretLength = 40

Variables

This section is empty.

Functions

func GenClientID

func GenClientID(appType models.AppType) string

func MuskClientSecrets

func MuskClientSecrets(clientSecrets []models.OauthClientSecret)

Types

type AuthorizeGenerateRequest

type AuthorizeGenerateRequest struct {
	ClientID    string
	RedirectURL string
	State       string

	Scope        string
	UserIdentify uint
	Request      *http.Request
}

type ClientIDGenerate

type ClientIDGenerate func(appType models.AppType) string

type CreateOAuthAppReq

type CreateOAuthAppReq struct {
	Name        string
	RedirectURI string
	HomeURL     string
	Desc        string
	OwnerType   models.OwnerType
	OwnerID     uint
	APPType     models.AppType
}

type Manager

type Manager interface {
	CreateOauthApp(ctx context.Context, info *CreateOAuthAppReq) (*models.OauthApp, error)
	GetOAuthApp(ctx context.Context, clientID string) (*models.OauthApp, error)
	DeleteOAuthApp(ctx context.Context, clientID string) error
	ListOauthApp(ctx context.Context, ownerType models.OwnerType, ownerID uint) ([]models.OauthApp, error)
	UpdateOauthApp(ctx context.Context, clientID string, req UpdateOauthAppReq) (*models.OauthApp, error)

	CreateSecret(ctx context.Context, clientID string) (*models.OauthClientSecret, error)
	DeleteSecret(ctx context.Context, ClientID string, clientSecretID uint) error
	ListSecret(ctx context.Context, ClientID string) ([]models.OauthClientSecret, error)

	GenAuthorizeCode(ctx context.Context, req *AuthorizeGenerateRequest) (*tokenmodels.Token, error)
	GenOauthTokens(ctx context.Context, req *OauthTokensRequest) (*OauthTokensResponse, error)
	RefreshOauthTokens(ctx context.Context, req *OauthTokensRequest) (*OauthTokensResponse, error)
}

type OauthManager

type OauthManager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(oauthAppDAO oauthdao.DAO, tokenStore tokenstore.Store,
	gen generator.CodeGenerator,
	authorizeCodeExpireTime,
	accessTokenExpireTime,
	refreshTokenExpireTime time.Duration) *OauthManager

func (*OauthManager) CreateOauthApp

func (m *OauthManager) CreateOauthApp(ctx context.Context, info *CreateOAuthAppReq) (*models.OauthApp, error)

func (*OauthManager) CreateSecret

func (m *OauthManager) CreateSecret(ctx context.Context, clientID string) (*models.OauthClientSecret, error)

func (*OauthManager) DeleteOAuthApp

func (m *OauthManager) DeleteOAuthApp(ctx context.Context, clientID string) error

func (*OauthManager) DeleteSecret

func (m *OauthManager) DeleteSecret(ctx context.Context, ClientID string, clientSecretID uint) error

func (*OauthManager) GenAuthorizeCode

func (m *OauthManager) GenAuthorizeCode(ctx context.Context,
	req *AuthorizeGenerateRequest) (*tokenmodels.Token, error)

func (*OauthManager) GenOauthTokens

func (m *OauthManager) GenOauthTokens(ctx context.Context, req *OauthTokensRequest) (*OauthTokensResponse, error)

func (*OauthManager) GetOAuthApp

func (m *OauthManager) GetOAuthApp(ctx context.Context, clientID string) (*models.OauthApp, error)

func (*OauthManager) ListOauthApp

func (m *OauthManager) ListOauthApp(ctx context.Context,
	ownerType models.OwnerType, ownerID uint) ([]models.OauthApp, error)

func (*OauthManager) ListSecret

func (m *OauthManager) ListSecret(ctx context.Context, ClientID string) ([]models.OauthClientSecret, error)

func (*OauthManager) NewAccessToken

func (m *OauthManager) NewAccessToken(authorizationCodeToken *tokenmodels.Token,
	req *OauthTokensRequest) *tokenmodels.Token

func (*OauthManager) NewAuthorizationToken

func (m *OauthManager) NewAuthorizationToken(req *AuthorizeGenerateRequest) *tokenmodels.Token

func (*OauthManager) NewRefreshToken

func (m *OauthManager) NewRefreshToken(accessToken *tokenmodels.Token,
	req *OauthTokensRequest) *tokenmodels.Token

func (*OauthManager) RefreshOauthTokens

func (m *OauthManager) RefreshOauthTokens(ctx context.Context,
	req *OauthTokensRequest) (*OauthTokensResponse, error)

func (*OauthManager) SetClientIDGenerate

func (m *OauthManager) SetClientIDGenerate(gen ClientIDGenerate)

func (*OauthManager) UpdateOauthApp

func (m *OauthManager) UpdateOauthApp(ctx context.Context, clientID string,
	req UpdateOauthAppReq) (*models.OauthApp, error)

type OauthTokensRequest

type OauthTokensRequest struct {
	ClientID     string
	ClientSecret string
	Code         string // authorization code
	RefreshToken string // refresh token
	RedirectURL  string

	Request *http.Request

	AccessTokenGenerator  generator.CodeGenerator
	RefreshTokenGenerator generator.CodeGenerator
}

type OauthTokensResponse

type OauthTokensResponse struct {
	AccessToken  *tokenmodels.Token
	RefreshToken *tokenmodels.Token
}

type UpdateOauthAppReq

type UpdateOauthAppReq struct {
	Name        string
	HomeURL     string
	RedirectURI string
	Desc        string
}

Jump to

Keyboard shortcuts

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