oauth2database

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: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//TimeFormat TimeFormat
	TimeFormat = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	ID             int64
	Token          string
	Expires        time.Time
	RefreshTokenID int64
}

AccessToken AccessToken

type AuthCodeRevolk

type AuthCodeRevolk struct {
	ID                int64
	AuthorizationCode int64
}

AuthCodeRevolk AuthCodeRevolk

type AuthCodeScope

type AuthCodeScope struct {
	ID                int64
	Scope             string
	AuthorizationCode int64
}

AuthCodeScope AuthCodeScope

type AuthorizationCode

type AuthorizationCode struct {
	AuthorizationCode int64
	ClientID          int64
	UserID            string
	Expires           time.Time
	AccessTokenID     int64
	RandonAuthCode    string
	AlreadyUsed       bool
	Scope             string
}

AuthorizationCode AuthorizationCode

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"`
}

Client Client

type ClientAllowedURI

type ClientAllowedURI struct {
	ID       int64
	URI      string
	ClientID int64
}

ClientAllowedURI ClientAllowedURI

type ClientGrantType

type ClientGrantType struct {
	ID        int64
	GrantType string
	ClientID  int64
}

ClientGrantType ClientGrantType

type ClientRedirectURI

type ClientRedirectURI struct {
	ID       int64
	URI      string
	ClientID int64
}

ClientRedirectURI ClientRedirectURI

type ClientRole

type ClientRole struct {
	ID       int64
	Role     string
	ClientID int64
}

ClientRole ClientRole

type ClientRoleURI

type ClientRoleURI struct {
	ClientRoleID       int64
	ClientAllowedURIID int64
}

ClientRoleURI ClientRoleURI

type ClientScope

type ClientScope struct {
	ID       int64
	Scope    string
	ClientID int64
}

ClientScope ClientScope

type CredentialsGrant

type CredentialsGrant struct {
	ID            int64
	ClientID      int64
	AccessTokenID int64
}

CredentialsGrant CredentialsGrant

type ImplicitGrant

type ImplicitGrant struct {
	ID            int64
	ClientID      int64
	UserID        string
	AccessTokenID int64
	Scope         string
}

ImplicitGrant ImplicitGrant

type ImplicitScope

type ImplicitScope struct {
	ID              int64
	Scope           string
	ImplicitGrantID int64
}

ImplicitScope ImplicitScope

type Oauth2DB

type Oauth2DB interface {
	//client
	AddClient(client *Client, uris *[]ClientRedirectURI) (bool, int64)
	UpdateClient(client *Client) bool
	GetClient(clientID int64) *Client
	GetClients() *[]Client
	SearchClients(name string) *[]Client
	DeleteClient(clientID int64) bool

	//Redirect URI
	AddClientRedirectURI(tx dbtx.Transaction, ru *ClientRedirectURI) (bool, int64)
	GetClientRedirectURIList(clientID int64) *[]ClientRedirectURI
	GetClientRedirectURI(clientID int64, uri string) *ClientRedirectURI
	DeleteClientRedirectURI(tx dbtx.Transaction, id int64) bool
	DeleteClientAllRedirectURI(tx dbtx.Transaction, clientID int64) bool

	//Allowed URI
	AddClientAllowedURI(au *ClientAllowedURI) (bool, int64)
	UpdateClientAllowedURI(au *ClientAllowedURI) bool
	GetClientAllowedURIByID(id int64) *ClientAllowedURI
	GetClientAllowedURIList(clientID int64) *[]ClientAllowedURI
	GetClientAllowedURI(clientID int64, uri string) *ClientAllowedURI
	DeleteClientAllowedURI(id int64) bool

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

	//Scope
	AddClientScope(s *ClientScope) (bool, int64)
	GetClientScopeList(clientID int64) *[]ClientScope
	DeleteClientScope(id int64) bool

	//Role URI
	AddClientRoleURI(r *ClientRoleURI) bool
	GetClientRoleAllowedURIList(roleID int64) *[]ClientRoleURI
	GetClientRoleAllowedURIListByClientID(clientID int64) *[]RoleURI
	DeleteClientRoleURI(r *ClientRoleURI) bool

	//Refresh Token
	AddRefreshToken(tx dbtx.Transaction, t *RefreshToken) (bool, int64)
	UpdateRefreshToken(t *RefreshToken) bool
	GetRefreshToken(id int64) *RefreshToken
	DeleteRefreshToken(tx dbtx.Transaction, id int64) bool

	//Access Token
	AddAccessToken(tx dbtx.Transaction, t *AccessToken) (bool, int64)
	UpdateAccessToken(tx dbtx.Transaction, t *AccessToken) bool
	GetAccessToken(id int64) *AccessToken
	DeleteAccessToken(tx dbtx.Transaction, id int64) bool

	//AuthorizationCode
	AddAuthorizationCode(code *AuthorizationCode, at *AccessToken, rt *RefreshToken, scopeList *[]string) (bool, int64)
	UpdateAuthorizationCode(code *AuthorizationCode) bool
	UpdateAuthorizationCodeAndToken(code *AuthorizationCode, at *AccessToken) bool
	GetAuthorizationCode(clientID int64, userID string) *[]AuthorizationCode
	GetAuthorizationCodeByCode(code string) *AuthorizationCode
	GetAuthorizationCodeByScope(clientID int64, userID string, scope string) *[]AuthorizationCode
	DeleteAuthorizationCode(clientID int64, userID string) bool

	//authcode revolk
	AddAuthCodeRevolk(tx dbtx.Transaction, rv *AuthCodeRevolk) (bool, int64)
	GetAuthCodeRevolk(ac int64) *AuthCodeRevolk
	DeleteAuthCodeRevolk(tx dbtx.Transaction, ac int64) bool

	//Auth code scope
	GetAuthorizationCodeScopeList(ac int64) *[]AuthCodeScope

	//grant types
	AddClientGrantType(gt *ClientGrantType) (bool, int64)
	GetClientGrantTypeList(cid int64) *[]ClientGrantType
	DeleteClientGrantType(id int64) bool

	//implicit grant
	AddImplicitGrant(ig *ImplicitGrant, at *AccessToken, scopeList *[]string) (bool, int64)
	GetImplicitGrant(clientID int64, userID string) *[]ImplicitGrant
	GetImplicitGrantByScope(clientID int64, userID string, scope string) *[]ImplicitGrant
	DeleteImplicitGrant(clientID int64, userID string) bool

	//implicit grant scope
	GetImplicitGrantScopeList(ig int64) *[]ImplicitScope

	// Password grand
	AddPasswordGrant(pwg *PasswordGrant, at *AccessToken, rt *RefreshToken) (bool, int64)
	GetPasswordGrant(clientID int64, userID string) *[]PasswordGrant
	DeletePasswordGrant(clientID int64, userID string) bool

	//credentials grant
	AddCredentialsGrant(cg *CredentialsGrant, at *AccessToken) (bool, int64)
	GetCredentialsGrant(clientID int64) *[]CredentialsGrant
	DeleteCredentialsGrant(clientID int64) bool

	// keys
	GetAccessTokenKey() string
	GetRefreshTokenKey() string
	GetSessionKey() string
}

Oauth2DB Oauth2DB

type PasswordGrant

type PasswordGrant struct {
	ID            int64
	ClientID      int64
	UserID        string
	AccessTokenID int64
}

PasswordGrant PasswordGrant

type RefreshToken

type RefreshToken struct {
	ID    int64
	Token string
}

RefreshToken RefreshToken

type RoleURI

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

RoleURI RoleURI

Jump to

Keyboard shortcuts

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