oauthstore

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sync

func Sync(dataStore *gorm.DB) *gorm.DB

Sync drops and rebuilds existing OAuth tables

Types

type BaseStore

type BaseStore interface {
	GetUserByExtID(string) (interface{}, error)
}

BaseStore is the interface required by the oauth module for underlying storage This defines required non-oauth methods

type OauthAccessToken

type OauthAccessToken struct {
	gorm.Model
	UserID    uint
	ClientID  uint
	Signature string
	OauthRequest
	OauthSession
}

OauthAccessToken Oauth Access token session

func (*OauthAccessToken) GetSession

func (oa *OauthAccessToken) GetSession() interface{}

func (*OauthAccessToken) GetSignature

func (oa *OauthAccessToken) GetSignature() string

func (*OauthAccessToken) SetSession

func (oa *OauthAccessToken) SetSession(session interface{})

type OauthAuthorizeCode

type OauthAuthorizeCode struct {
	gorm.Model
	ClientID        uint
	UserID          uint
	Code            string // Authorization code
	Challenge       string // Optional code_challenge as described in rfc7636
	ChallengeMethod string // Optional code_challenge_method as described in rfc7636
	OauthRequest
	OauthSession
}

OauthAuthorizeCode Authorization data

func (*OauthAuthorizeCode) GetCode

func (oa *OauthAuthorizeCode) GetCode() string

func (*OauthAuthorizeCode) GetSession

func (oa *OauthAuthorizeCode) GetSession() interface{}

func (*OauthAuthorizeCode) SetSession

func (oa *OauthAuthorizeCode) SetSession(session interface{})

type OauthClient

type OauthClient struct {
	ID        uint      `gorm:"primary_key" description:"Internal Database ID"`
	CreatedAt time.Time `description:"Creation time"`
	UpdatedAt time.Time `description:"Last update time"`
	ClientID  string    `gorm:"unique"`
	Name      string    `gorm:"unique"`
	UserID    uint
	LastUsed  time.Time
	Secret    string

	Scopes        string
	RedirectURIs  string
	GrantTypes    string
	ResponseTypes string

	UserData string
	Public   bool
}

OauthClient is a client application registration

func (*OauthClient) GetCreatedAt

func (c *OauthClient) GetCreatedAt() time.Time

func (*OauthClient) GetGrantTypes

func (c *OauthClient) GetGrantTypes() []string

func (*OauthClient) GetID

func (c *OauthClient) GetID() string

func (*OauthClient) GetLastUsed

func (c *OauthClient) GetLastUsed() time.Time

func (*OauthClient) GetName

func (c *OauthClient) GetName() string

func (*OauthClient) GetRedirectURIs

func (c *OauthClient) GetRedirectURIs() []string

func (*OauthClient) GetResponseTypes

func (c *OauthClient) GetResponseTypes() []string

func (*OauthClient) GetScopes

func (c *OauthClient) GetScopes() []string

func (*OauthClient) GetSecret

func (c *OauthClient) GetSecret() string

func (*OauthClient) GetUserData

func (c *OauthClient) GetUserData() interface{}

func (*OauthClient) IsPublic

func (c *OauthClient) IsPublic() bool

func (*OauthClient) SetGrantTypes

func (c *OauthClient) SetGrantTypes(grantTypes []string)

func (*OauthClient) SetID

func (c *OauthClient) SetID(id string)

func (*OauthClient) SetLastUsed

func (c *OauthClient) SetLastUsed(t time.Time)

func (*OauthClient) SetRedirectURIs

func (c *OauthClient) SetRedirectURIs(redirectURIs []string)

func (*OauthClient) SetResponseTypes

func (c *OauthClient) SetResponseTypes(responseTypes []string)

func (*OauthClient) SetScopes

func (c *OauthClient) SetScopes(scopes []string)

func (*OauthClient) SetSecret

func (c *OauthClient) SetSecret(secret string)

func (*OauthClient) SetUserData

func (c *OauthClient) SetUserData(userData string)

type OauthRefreshToken

type OauthRefreshToken struct {
	gorm.Model
	UserID    uint
	ClientID  uint
	Signature string
	OauthRequest
	OauthSession
}

OauthRefreshToken Refresh token storage

func (*OauthRefreshToken) GetSession

func (or *OauthRefreshToken) GetSession() interface{}

func (*OauthRefreshToken) GetSignature

func (or *OauthRefreshToken) GetSignature() string

GetSignature fetches the Refresh token signature

func (*OauthRefreshToken) SetSession

func (or *OauthRefreshToken) SetSession(session interface{})

type OauthRequest

type OauthRequest struct {
	RequestID       string
	RequestedAt     time.Time
	ExpiresAt       time.Time
	RequestedScopes string
	GrantedScopes   string
	Form            string
	Client          OauthClient  `sql:"-"`
	Session         OauthSession `sql:"-"`
}

OauthRequest Base Type This is not stored directly, but used in other oauth types

func (*OauthRequest) AppendRequestedScope

func (c *OauthRequest) AppendRequestedScope(scope string)

func (*OauthRequest) GetClient

func (or *OauthRequest) GetClient() interface{}

func (*OauthRequest) GetExpiresAt

func (or *OauthRequest) GetExpiresAt() time.Time

func (*OauthRequest) GetGrantedScopes

func (c *OauthRequest) GetGrantedScopes() []string

func (*OauthRequest) GetRequestID

func (or *OauthRequest) GetRequestID() string

func (*OauthRequest) GetRequestedAt

func (or *OauthRequest) GetRequestedAt() time.Time

func (*OauthRequest) GetRequestedScopes

func (c *OauthRequest) GetRequestedScopes() []string

func (*OauthRequest) GetSession

func (or *OauthRequest) GetSession() interface{}

func (*OauthRequest) GrantScope

func (c *OauthRequest) GrantScope(scope string)

func (*OauthRequest) Merge

func (c *OauthRequest) Merge(a interface{})

func (*OauthRequest) SetGrantedScopes

func (c *OauthRequest) SetGrantedScopes(scopes []string)

func (*OauthRequest) SetRequestID

func (or *OauthRequest) SetRequestID(id string)

func (*OauthRequest) SetRequestedScopes

func (c *OauthRequest) SetRequestedScopes(scopes []string)

type OauthSession

type OauthSession struct {
	UserExtID       string
	Username        string
	Subject         string
	AccessExpiry    time.Time
	RefreshExpiry   time.Time
	AuthorizeExpiry time.Time
	IDExpiry        time.Time
}

OauthSession session storage base type Used by grants for session storage

func NewSession

func NewSession(userID, username string) OauthSession

NewSession creates an OauthSession

func (*OauthSession) Clone

func (s *OauthSession) Clone() interface{}

func (*OauthSession) GetAccessExpiry

func (s *OauthSession) GetAccessExpiry() time.Time

func (*OauthSession) GetAuthorizeExpiry

func (s *OauthSession) GetAuthorizeExpiry() time.Time

func (*OauthSession) GetIDExpiry

func (s *OauthSession) GetIDExpiry() time.Time

func (*OauthSession) GetRefreshExpiry

func (s *OauthSession) GetRefreshExpiry() time.Time

func (*OauthSession) GetSession

func (s *OauthSession) GetSession() interface{}

func (*OauthSession) GetSubject

func (s *OauthSession) GetSubject() string

func (*OauthSession) GetUserID

func (s *OauthSession) GetUserID() string

func (*OauthSession) GetUsername

func (s *OauthSession) GetUsername() string

func (*OauthSession) SetAccessExpiry

func (s *OauthSession) SetAccessExpiry(t time.Time)

func (*OauthSession) SetAuthorizeExpiry

func (s *OauthSession) SetAuthorizeExpiry(t time.Time)

func (*OauthSession) SetIDExpiry

func (s *OauthSession) SetIDExpiry(t time.Time)

func (*OauthSession) SetRefreshExpiry

func (s *OauthSession) SetRefreshExpiry(t time.Time)

type OauthStore

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

OauthStore is a storage instance for OAuth components

func NewOauthStore

func NewOauthStore(db *gorm.DB, baseStore BaseStore) *OauthStore

NewOauthStore creates an oauthstore from a provided gorm.DB and baseStore instance

func (*OauthStore) AddAccessTokenSession

func (os *OauthStore) AddAccessTokenSession(userID, clientID, signature, requestID string,
	requestedAt, expiresAt time.Time, requestedScopes, grantedScopes []string) (interface{}, error)

func (*OauthStore) AddAuthorizeCodeSession

func (oauthStore *OauthStore) AddAuthorizeCodeSession(userID, clientID, code, requestID string,
	requestedAt, expiresAt time.Time, requestedScopes, grantedScopes []string) (interface{}, error)

AddAuthorizeCodeSession creates an authorization code session in the database

func (*OauthStore) AddClient

func (oauthStore *OauthStore) AddClient(userID, clientID, clientName, secret string,
	scopes, redirects, grantTypes, responseTypes []string, public bool) (interface{}, error)

AddClient adds an OAuth2 client application to the database

func (*OauthStore) AddRefreshTokenSession

func (os *OauthStore) AddRefreshTokenSession(userID, clientID, signature, requestID string,
	requestedAt, expiresAt time.Time, requestedScopes, grantedScopes []string) (interface{}, error)

AddRefreshTokenSession creates a refresh token session in the database

func (*OauthStore) GetAccessTokenSession

func (os *OauthStore) GetAccessTokenSession(signature string) (interface{}, error)

GetAccessTokenSession Fetch a client from an access token

func (*OauthStore) GetAccessTokenSessionByRequestID

func (os *OauthStore) GetAccessTokenSessionByRequestID(requestID string) (interface{}, error)

GetAccessTokenSessionByRequestID fetch an access token by refresh id

func (*OauthStore) GetAccessTokenSessionsByUserID

func (os *OauthStore) GetAccessTokenSessionsByUserID(userID string) ([]interface{}, error)

GetAccessTokenSessionsByUserID by a user id

func (*OauthStore) GetAuthorizeCodeSession

func (oauthStore *OauthStore) GetAuthorizeCodeSession(code string) (interface{}, error)

GetAuthorizeCodeSession fetches an authorization code session

func (*OauthStore) GetAuthorizeCodeSessionByRequestID

func (oauthStore *OauthStore) GetAuthorizeCodeSessionByRequestID(requestID string) (interface{}, error)

GetAuthorizeCodeSessionByRequestID fetches an authorization code session by the originator request ID

func (*OauthStore) GetAuthorizeCodeSessionsByUserID

func (os *OauthStore) GetAuthorizeCodeSessionsByUserID(userID string) ([]interface{}, error)

func (*OauthStore) GetClientByAccessTokenSession

func (os *OauthStore) GetClientByAccessTokenSession(signature string) (interface{}, error)

GetClientByAccessTokenSession Fetch a client from an access token

func (*OauthStore) GetClientByID

func (oauthStore *OauthStore) GetClientByID(clientID string) (interface{}, error)

GetClientByID an oauth client app by ClientID

func (*OauthStore) GetClientByRefreshToken

func (os *OauthStore) GetClientByRefreshToken(signature string) (interface{}, error)

Fetch a client from an access token

func (*OauthStore) GetClientsByUserID

func (oauthStore *OauthStore) GetClientsByUserID(userID string) ([]interface{}, error)

GetClientsByUserID fetches the OauthClients for a provided userID

func (*OauthStore) GetRefreshTokenBySignature

func (os *OauthStore) GetRefreshTokenBySignature(signature string) (interface{}, error)

Fetch a client from an access token

func (*OauthStore) GetRefreshTokenSessionByRequestID

func (os *OauthStore) GetRefreshTokenSessionByRequestID(requestID string) (interface{}, error)

func (*OauthStore) GetRefreshTokenSessionsByUserID

func (os *OauthStore) GetRefreshTokenSessionsByUserID(userID string) ([]interface{}, error)

func (*OauthStore) RemoveAccessTokenSession

func (os *OauthStore) RemoveAccessTokenSession(signature string) error

RemoveAccessTokenSession Remove an access token by session key

func (*OauthStore) RemoveAuthorizeCodeSession

func (oauthStore *OauthStore) RemoveAuthorizeCodeSession(code string) error

RemoveAuthorizeCodeSession removes an authorization code session using the provided code

func (*OauthStore) RemoveClientByID

func (oauthStore *OauthStore) RemoveClientByID(clientID string) error

RemoveClientByID removes a client application by id

func (*OauthStore) RemoveRefreshToken

func (os *OauthStore) RemoveRefreshToken(signature string) error

func (*OauthStore) Sync

func (os *OauthStore) Sync(force bool) *gorm.DB

Sync Synchronizes the database Force causes existing table to be dropped

func (*OauthStore) UpdateClient

func (oauthStore *OauthStore) UpdateClient(client interface{}) (interface{}, error)

UpdateClient Update a user object

type User

type User interface {
	GetIntID() uint
	GetExtID() string
	GetUsername() string
}

User defines the user interface required by the Oauth2 storage module

Jump to

Keyboard shortcuts

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