managers

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package managers ...

Package managers ...

Package managers ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthCode

type AuthCode struct {
	ClientID    int64
	UserID      string
	Scope       string
	RedirectURI string
	CallbackURI string
}

AuthCode AuthCode

type AuthCodeClient

type AuthCodeClient struct {
	Valid      bool
	ClientName string
	WebSite    string
}

AuthCodeClient AuthCodeClient

type AuthCodeTokenReq

type AuthCodeTokenReq struct {
	ClientID    int64
	Secret      string
	Code        string
	RedirectURI string
}

AuthCodeTokenReq AuthCodeTokenReq

type Client

type Client struct {
	ClientID     int64                `json:"clientId"`
	Secret       string               `json:"secret"`
	Name         string               `json:"name"`
	WebSite      string               `json:"webSite"`
	Email        string               `json:"email"`
	Enabled      bool                 `json:"enabled"`
	Paid         bool                 `json:"paid"`
	RedirectURIs *[]ClientRedirectURI `json:"redirectUrls"`
}

Client Client

type ClientAllowedURI

type ClientAllowedURI struct {
	ID       int64  `json:"id"`
	URI      string `json:"uri"`
	ClientID int64  `json:"clientId"`
}

ClientAllowedURI ClientAllowedURI

type ClientGrantType

type ClientGrantType struct {
	ID        int64  `json:"id"`
	GrantType string `json:"grantType"`
	ClientID  int64  `json:"clientId"`
}

ClientGrantType ClientGrantType

type ClientRedirectURI

type ClientRedirectURI struct {
	ID       int64  `json:"id"`
	URI      string `json:"uri"`
	ClientID int64  `json:"clientId"`
}

ClientRedirectURI ClientRedirectURI

type ClientRole

type ClientRole struct {
	ID       int64  `json:"id"`
	Role     string `json:"role"`
	ClientID int64  `json:"clientId"`
}

ClientRole ClientRole

type ClientRoleURI

type ClientRoleURI struct {
	ClientRoleID       int64 `json:"clientRoleId"`
	ClientAllowedURIID int64 `json:"clientAllowedUriId"`
}

ClientRoleURI ClientRoleURI

type CredentialsTokenReq

type CredentialsTokenReq struct {
	ClientID int64
	Secret   string
}

CredentialsTokenReq CredentialsTokenReq

type Implicit

type Implicit struct {
	ClientID    int64
	UserID      string
	Scope       string
	RedirectURI string
	CallbackURI string
}

Implicit Implicit

type ImplicitClient

type ImplicitClient struct {
	Valid      bool
	ClientName string
	WebSite    string
}

ImplicitClient ImplicitClient

type ImplicitReturn

type ImplicitReturn struct {
	ID    int64
	Token string
}

ImplicitReturn ImplicitReturn

type Login

type Login struct {
	Username string `json:"username"`
	Password string `json:"password"`
	ClientID int64  `json:"clientId"`
}

Login Login

type LoginRes

type LoginRes struct {
	Valid bool   `json:"valid"`
	Code  string `json:"code"`
}

LoginRes LoginRes

type Manager

type Manager interface {
	//client
	AddClient(client *Client) (bool, int64)
	UpdateClient(client *Client) bool
	GetClient(id int64) *Client
	GetClientList() *[]Client
	GetClientSearchList(name string) *[]Client
	DeleteClient(id int64) bool

	//client redirect uri
	AddClientRedirectURI(ru *ClientRedirectURI) (bool, int64)
	GetClientRedirectURIList(clientID int64) *[]ClientRedirectURI
	DeleteClientRedirectURI(id int64) bool

	// //client roles
	AddClientRole(r *ClientRole) (bool, int64)
	GetClientRoleList(clientID int64) *[]ClientRole
	DeleteClientRole(id int64) bool

	//client allowed uri
	AddClientAllowedURI(au *ClientAllowedURI) (bool, int64)
	UpdateClientAllowedURI(au *ClientAllowedURI) bool
	GetClientAllowedURI(id int64) *ClientAllowedURI
	GetClientAllowedURIList(clientID int64) *[]ClientAllowedURI
	DeleteClientAllowedURI(id int64) bool

	//client role uri
	AddClientRoleURI(r *ClientRoleURI) bool
	GetClientRoleAllowedURIList(roleID int64) *[]ClientRoleURI
	DeleteClientRoleURI(r *ClientRoleURI) bool

	//client grant type
	AddClientGrantType(gt *ClientGrantType) (bool, int64)
	GetClientGrantTypeList(clientID int64) *[]ClientGrantType
	DeleteClientGrantType(id int64) bool

	//auth code
	AuthorizeAuthCode(ac *AuthCode) (success bool, authCode int64, authCodeString string)
	CheckAuthCodeApplicationAuthorization(ac *AuthCode) (authorized bool)
	ValidateAuthCodeClientAndCallback(ac *AuthCode) *AuthCodeClient

	//implicit
	AuthorizeImplicit(imp *Implicit) (bool, *ImplicitReturn)
	CheckImplicitApplicationAuthorization(imp *Implicit) (authorized bool)
	ValidateImplicitClientAndCallback(imp *Implicit) *ImplicitClient

	//token manager
	GetAuthCodeToken(act *AuthCodeTokenReq) (bool, *Token, string)
	GetCredentialsToken(ct *CredentialsTokenReq) (bool, *Token, string)
	GetPasswordToken(pt *PasswordTokenReq) (bool, *Token, string)
	GetAuthCodeAccesssTokenWithRefreshToken(rt *RefreshTokenReq) (bool, *Token, string)
	GetPasswordAccesssTokenWithRefreshToken(rt *RefreshTokenReq) (bool, *Token, string)

	// //validate Token
	ValidateAccessToken(at *ValidateAccessTokenReq) bool

	UserLogin(login *au.Login) bool
}

Manager Manager

type MockManager

type MockManager struct {
	MockInsertSuccess1 bool
	MockInsertID1      int64

	MockUpdateSuccess1 bool
	MockDeleteSuccess1 bool

	MockClient     Client
	MockClientList []Client

	MockClientRedirectURIList []ClientRedirectURI
	MockClientRoleList        []ClientRole

	MockClientAllowedURI     ClientAllowedURI
	MockClientAllowedURIList []ClientAllowedURI

	MockClientRoleURIList []ClientRoleURI

	MockClientGrantTypeList []ClientGrantType

	MockAuthCodeAuthorizeSuccess bool
	MockAuthCode                 int64
	MockAuthCodeString           string

	MockAuthCodeAuthorized bool

	MockAuthCodeClient AuthCodeClient

	MockImplicitAuthorizeSuccess bool
	MockImplicitReturn           ImplicitReturn
	MockImplicitAuthorized       bool
	MockImplicitClient           ImplicitClient

	MockToken                       Token
	MockAuthCodeTokenSuccess        bool
	MockCredentialsTokenSuccess     bool
	MockPasswordTokenSuccess        bool
	MockAuthCodeRefreshTokenSuccess bool
	MockPasswordRefreshTokenSuccess bool

	MockTokenError string

	MockValidateAccessTokenSuccess bool

	MockUserLoginSuccess bool
}

MockManager MockManager

func (*MockManager) AddClient

func (m *MockManager) AddClient(client *Client) (bool, int64)

AddClient AddClient

func (*MockManager) AddClientAllowedURI

func (m *MockManager) AddClientAllowedURI(au *ClientAllowedURI) (bool, int64)

AddClientAllowedURI AddClientAllowedURI

func (*MockManager) AddClientGrantType

func (m *MockManager) AddClientGrantType(gt *ClientGrantType) (bool, int64)

AddClientGrantType AddClientGrantType

func (*MockManager) AddClientRedirectURI

func (m *MockManager) AddClientRedirectURI(ru *ClientRedirectURI) (bool, int64)

AddClientRedirectURI AddClientRedirectURI

func (*MockManager) AddClientRole

func (m *MockManager) AddClientRole(r *ClientRole) (bool, int64)

AddClientRole AddClientRole

func (*MockManager) AddClientRoleURI

func (m *MockManager) AddClientRoleURI(r *ClientRoleURI) bool

AddClientRoleURI AddClientRoleURI

func (*MockManager) AuthorizeAuthCode

func (m *MockManager) AuthorizeAuthCode(ac *AuthCode) (success bool, authCode int64, authCodeString string)

AuthorizeAuthCode AuthorizeAuthCode

func (*MockManager) AuthorizeImplicit

func (m *MockManager) AuthorizeImplicit(imp *Implicit) (bool, *ImplicitReturn)

AuthorizeImplicit AuthorizeImplicit

func (*MockManager) CheckAuthCodeApplicationAuthorization

func (m *MockManager) CheckAuthCodeApplicationAuthorization(ac *AuthCode) (authorized bool)

CheckAuthCodeApplicationAuthorization CheckAuthCodeApplicationAuthorization

func (*MockManager) CheckImplicitApplicationAuthorization

func (m *MockManager) CheckImplicitApplicationAuthorization(imp *Implicit) (authorized bool)

CheckImplicitApplicationAuthorization CheckImplicitApplicationAuthorization

func (*MockManager) DeleteClient

func (m *MockManager) DeleteClient(id int64) bool

DeleteClient DeleteClient

func (*MockManager) DeleteClientAllowedURI

func (m *MockManager) DeleteClientAllowedURI(id int64) bool

DeleteClientAllowedURI DeleteClientAllowedURI

func (*MockManager) DeleteClientGrantType

func (m *MockManager) DeleteClientGrantType(id int64) bool

DeleteClientGrantType DeleteClientGrantType

func (*MockManager) DeleteClientRedirectURI

func (m *MockManager) DeleteClientRedirectURI(id int64) bool

DeleteClientRedirectURI DeleteClientRedirectURI

func (*MockManager) DeleteClientRole

func (m *MockManager) DeleteClientRole(id int64) bool

DeleteClientRole DeleteClientRole

func (*MockManager) DeleteClientRoleURI

func (m *MockManager) DeleteClientRoleURI(r *ClientRoleURI) bool

DeleteClientRoleURI DeleteClientRoleURI

func (*MockManager) GetAuthCodeAccesssTokenWithRefreshToken

func (m *MockManager) GetAuthCodeAccesssTokenWithRefreshToken(rt *RefreshTokenReq) (bool, *Token, string)

GetAuthCodeAccesssTokenWithRefreshToken GetAuthCodeAccesssTokenWithRefreshToken

func (*MockManager) GetAuthCodeToken

func (m *MockManager) GetAuthCodeToken(act *AuthCodeTokenReq) (bool, *Token, string)

GetAuthCodeToken GetAuthCodeToken

func (*MockManager) GetClient

func (m *MockManager) GetClient(id int64) *Client

GetClient GetClient

func (*MockManager) GetClientAllowedURI

func (m *MockManager) GetClientAllowedURI(id int64) *ClientAllowedURI

GetClientAllowedURI GetClientAllowedURI

func (*MockManager) GetClientAllowedURIList

func (m *MockManager) GetClientAllowedURIList(clientID int64) *[]ClientAllowedURI

GetClientAllowedURIList GetClientAllowedURIList

func (*MockManager) GetClientGrantTypeList

func (m *MockManager) GetClientGrantTypeList(clientID int64) *[]ClientGrantType

GetClientGrantTypeList GetClientGrantTypeList

func (*MockManager) GetClientList

func (m *MockManager) GetClientList() *[]Client

GetClientList GetClientList

func (*MockManager) GetClientRedirectURIList

func (m *MockManager) GetClientRedirectURIList(clientID int64) *[]ClientRedirectURI

GetClientRedirectURIList GetClientRedirectURIList

func (*MockManager) GetClientRoleAllowedURIList

func (m *MockManager) GetClientRoleAllowedURIList(roleID int64) *[]ClientRoleURI

GetClientRoleAllowedURIList GetClientRoleAllowedURIList

func (*MockManager) GetClientRoleList

func (m *MockManager) GetClientRoleList(clientID int64) *[]ClientRole

GetClientRoleList GetClientRoleList

func (*MockManager) GetClientSearchList

func (m *MockManager) GetClientSearchList(name string) *[]Client

GetClientSearchList GetClientSearchList

func (*MockManager) GetCredentialsToken

func (m *MockManager) GetCredentialsToken(ct *CredentialsTokenReq) (bool, *Token, string)

GetCredentialsToken GetCredentialsToken

func (*MockManager) GetPasswordAccesssTokenWithRefreshToken

func (m *MockManager) GetPasswordAccesssTokenWithRefreshToken(rt *RefreshTokenReq) (bool, *Token, string)

GetPasswordAccesssTokenWithRefreshToken GetPasswordAccesssTokenWithRefreshToken

func (*MockManager) GetPasswordToken

func (m *MockManager) GetPasswordToken(pt *PasswordTokenReq) (bool, *Token, string)

GetPasswordToken GetPasswordToken

func (*MockManager) UpdateClient

func (m *MockManager) UpdateClient(client *Client) bool

UpdateClient UpdateClient

func (*MockManager) UpdateClientAllowedURI

func (m *MockManager) UpdateClientAllowedURI(au *ClientAllowedURI) bool

UpdateClientAllowedURI UpdateClientAllowedURI

func (*MockManager) UserLogin

func (m *MockManager) UserLogin(login *au.Login) bool

UserLogin UserLogin

func (*MockManager) ValidateAccessToken

func (m *MockManager) ValidateAccessToken(at *ValidateAccessTokenReq) bool

ValidateAccessToken ValidateAccessToken

func (*MockManager) ValidateAuthCodeClientAndCallback

func (m *MockManager) ValidateAuthCodeClientAndCallback(ac *AuthCode) *AuthCodeClient

ValidateAuthCodeClientAndCallback ValidateAuthCodeClientAndCallback

func (*MockManager) ValidateImplicitClientAndCallback

func (m *MockManager) ValidateImplicitClientAndCallback(imp *Implicit) *ImplicitClient

ValidateImplicitClientAndCallback ValidateImplicitClientAndCallback

type OauthManager

type OauthManager struct {
	Db          odb.Oauth2DB
	Proxy       px.Proxy
	AuthService au.AuthInterface
	Log         *lg.Logger
	TokenParams *TokenParams
}

OauthManager OauthManager

func (*OauthManager) AddClient

func (m *OauthManager) AddClient(client *Client) (bool, int64)

AddClient AddClient

func (*OauthManager) AddClientAllowedURI

func (m *OauthManager) AddClientAllowedURI(au *ClientAllowedURI) (bool, int64)

AddClientAllowedURI AddClientAllowedURI

func (*OauthManager) AddClientGrantType

func (m *OauthManager) AddClientGrantType(gt *ClientGrantType) (bool, int64)

AddClientGrantType AddClientGrantType

func (*OauthManager) AddClientRedirectURI

func (m *OauthManager) AddClientRedirectURI(ru *ClientRedirectURI) (bool, int64)

AddClientRedirectURI AddClientRedirectURI

func (*OauthManager) AddClientRole

func (m *OauthManager) AddClientRole(r *ClientRole) (bool, int64)

AddClientRole AddClientRole

func (*OauthManager) AddClientRoleURI

func (m *OauthManager) AddClientRoleURI(r *ClientRoleURI) bool

AddClientRoleURI AddClientRoleURI

func (*OauthManager) AuthorizeAuthCode

func (m *OauthManager) AuthorizeAuthCode(ac *AuthCode) (success bool, authCode int64, authCodeString string)

AuthorizeAuthCode AuthorizeAuthCode

func (*OauthManager) AuthorizeImplicit

func (m *OauthManager) AuthorizeImplicit(imp *Implicit) (bool, *ImplicitReturn)

AuthorizeImplicit AuthorizeImplicit

func (*OauthManager) CheckAuthCodeApplicationAuthorization

func (m *OauthManager) CheckAuthCodeApplicationAuthorization(ac *AuthCode) (authorized bool)

CheckAuthCodeApplicationAuthorization CheckAuthCodeApplicationAuthorization

func (*OauthManager) CheckImplicitApplicationAuthorization

func (m *OauthManager) CheckImplicitApplicationAuthorization(imp *Implicit) (authorized bool)

CheckImplicitApplicationAuthorization CheckImplicitApplicationAuthorization

func (*OauthManager) DeleteClient

func (m *OauthManager) DeleteClient(id int64) bool

DeleteClient DeleteClient

func (*OauthManager) DeleteClientAllowedURI

func (m *OauthManager) DeleteClientAllowedURI(id int64) bool

DeleteClientAllowedURI DeleteClientAllowedURI

func (*OauthManager) DeleteClientGrantType

func (m *OauthManager) DeleteClientGrantType(id int64) bool

DeleteClientGrantType DeleteClientGrantType

func (*OauthManager) DeleteClientRedirectURI

func (m *OauthManager) DeleteClientRedirectURI(id int64) bool

DeleteClientRedirectURI DeleteClientRedirectURI

func (*OauthManager) DeleteClientRole

func (m *OauthManager) DeleteClientRole(id int64) bool

DeleteClientRole DeleteClientRole

func (*OauthManager) DeleteClientRoleURI

func (m *OauthManager) DeleteClientRoleURI(r *ClientRoleURI) bool

DeleteClientRoleURI DeleteClientRoleURI

func (*OauthManager) GenerateAccessToken

func (m *OauthManager) GenerateAccessToken(pl *Payload) string

GenerateAccessToken GenerateAccessToken

func (*OauthManager) GenerateJwtToken

func (m *OauthManager) GenerateJwtToken(pl *Payload) string

GenerateJwtToken GenerateJwtToken

func (*OauthManager) GenerateRefreshToken

func (m *OauthManager) GenerateRefreshToken(clientID int64, userID string, grantType string) string

GenerateRefreshToken GenerateRefreshToken

func (*OauthManager) GetAuthCodeAccesssTokenWithRefreshToken

func (m *OauthManager) GetAuthCodeAccesssTokenWithRefreshToken(rt *RefreshTokenReq) (bool, *Token, string)

GetAuthCodeAccesssTokenWithRefreshToken GetAuthCodeAccesssTokenWithRefreshToken

func (*OauthManager) GetAuthCodeToken

func (m *OauthManager) GetAuthCodeToken(act *AuthCodeTokenReq) (bool, *Token, string)

GetAuthCodeToken GetAuthCodeToken

func (*OauthManager) GetClient

func (m *OauthManager) GetClient(id int64) *Client

GetClient GetClient

func (*OauthManager) GetClientAllowedURI

func (m *OauthManager) GetClientAllowedURI(id int64) *ClientAllowedURI

GetClientAllowedURI GetClientAllowedURI

func (*OauthManager) GetClientAllowedURIList

func (m *OauthManager) GetClientAllowedURIList(clientID int64) *[]ClientAllowedURI

GetClientAllowedURIList GetClientAllowedURIList

func (*OauthManager) GetClientGrantTypeList

func (m *OauthManager) GetClientGrantTypeList(clientID int64) *[]ClientGrantType

GetClientGrantTypeList GetClientGrantTypeList

func (*OauthManager) GetClientList

func (m *OauthManager) GetClientList() *[]Client

GetClientList GetClientList

func (*OauthManager) GetClientRedirectURIList

func (m *OauthManager) GetClientRedirectURIList(clientID int64) *[]ClientRedirectURI

GetClientRedirectURIList GetClientRedirectURIList

func (*OauthManager) GetClientRoleAllowedURIList

func (m *OauthManager) GetClientRoleAllowedURIList(roleID int64) *[]ClientRoleURI

GetClientRoleAllowedURIList GetClientRoleAllowedURIList

func (*OauthManager) GetClientRoleList

func (m *OauthManager) GetClientRoleList(clientID int64) *[]ClientRole

GetClientRoleList GetClientRoleList

func (*OauthManager) GetClientSearchList

func (m *OauthManager) GetClientSearchList(name string) *[]Client

GetClientSearchList GetClientSearchList

func (*OauthManager) GetCredentialsToken

func (m *OauthManager) GetCredentialsToken(ct *CredentialsTokenReq) (bool, *Token, string)

GetCredentialsToken GetCredentialsToken

func (*OauthManager) GetPasswordAccesssTokenWithRefreshToken

func (m *OauthManager) GetPasswordAccesssTokenWithRefreshToken(rt *RefreshTokenReq) (bool, *Token, string)

GetPasswordAccesssTokenWithRefreshToken GetPasswordAccesssTokenWithRefreshToken

func (*OauthManager) GetPasswordToken

func (m *OauthManager) GetPasswordToken(pt *PasswordTokenReq) (bool, *Token, string)

GetPasswordToken GetPasswordToken

func (*OauthManager) UpdateClient

func (m *OauthManager) UpdateClient(client *Client) bool

UpdateClient UpdateClient

func (*OauthManager) UpdateClientAllowedURI

func (m *OauthManager) UpdateClientAllowedURI(au *ClientAllowedURI) bool

UpdateClientAllowedURI UpdateClientAllowedURI

func (*OauthManager) UserLogin

func (m *OauthManager) UserLogin(login *au.Login) bool

UserLogin UserLogin

func (*OauthManager) ValidateAccessToken

func (m *OauthManager) ValidateAccessToken(at *ValidateAccessTokenReq) bool

ValidateAccessToken ValidateAccessToken

func (*OauthManager) ValidateAuthCodeClientAndCallback

func (m *OauthManager) ValidateAuthCodeClientAndCallback(ac *AuthCode) *AuthCodeClient

ValidateAuthCodeClientAndCallback ValidateAuthCodeClientAndCallback

func (*OauthManager) ValidateImplicitClientAndCallback

func (m *OauthManager) ValidateImplicitClientAndCallback(imp *Implicit) *ImplicitClient

ValidateImplicitClientAndCallback ValidateImplicitClientAndCallback

func (*OauthManager) ValidateJwt

func (m *OauthManager) ValidateJwt(token string, secret string) (bool, *Payload)

ValidateJwt ValidateJwt

type PasswordTokenReq

type PasswordTokenReq struct {
	Username string
	// Password string
	ClientID int64
}

PasswordTokenReq PasswordTokenReq

type Payload

type Payload struct {
	TokenType       string
	UserID          string
	ClientID        int64
	Subject         string
	Issuer          string
	Audience        string
	ExpiresInMinute time.Duration
	Grant           string
	SecretKey       string
	RoleURIs        []RoleURI
	ScopeList       []string
}

Payload Payload

type RefreshTokenReq

type RefreshTokenReq struct {
	ClientID     int64
	Secret       string
	RefreshToken string
}

RefreshTokenReq RefreshTokenReq

type RoleURI

type RoleURI struct {
	ClientRoleID       int64
	Role               string
	ClientAllowedURIID int64
	ClientAllowedURI   string
	ClientID           int64
}

RoleURI RoleURI

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

Token Token

type TokenParams added in v0.1.2

type TokenParams struct {
	AccessTokenKey  string
	RefreshTokenKey string
	Issuer          string
	Audience        string
}

TokenParams AccessTokenParams

type ValidateAccessTokenReq

type ValidateAccessTokenReq struct {
	AccessToken string `json:"accessToken"`
	Hashed      bool   `json:"hashed"`
	UserID      string `json:"userId"`
	ClientID    int64  `json:"clientId"`
	Role        string `json:"role"`
	URI         string `json:"url"`
	Scope       string `json:"scope"`
}

ValidateAccessTokenReq ValidateAccessTokenReq

Jump to

Keyboard shortcuts

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