oidc

package
v1.49.5 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KindUnknown is used to represent an entry for which we do not recognize the value.
	KindUnknown = 0
	// KindAccessToken represents an access token within the database.
	KindAccessToken = 1
	// KindRefreshToken represents a refresh token within the database.
	KindRefreshToken = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// OAuthClients returns an API for the oauthclients repository.
	OAuthClients() OAuthClients
	// OAuthCodes returns an API for the oauthcodes repository.
	OAuthCodes() OAuthCodes
	// OAuthTokens returns an API for the oauthtokens repository.
	OAuthTokens() OAuthTokens
}

DB defines a collection of resources that fall under the scope of OIDC and OAuth operations.

architecture: Database

func NewDB

func NewDB(dbxdb *dbx.DB) DB

NewDB constructs a database using the provided dbx db.

type OAuthClient

type OAuthClient struct {
	ID          uuid.UUID `json:"id"`
	Secret      []byte    `json:"secret"`
	UserID      uuid.UUID `json:"userID"`
	RedirectURL string    `json:"redirectURL"`
	AppName     string    `json:"appName"`
	AppLogoURL  string    `json:"appLogoURL"`
}

OAuthClient defines a concrete representation of an oauth client.

func (OAuthClient) GetDomain

func (o OAuthClient) GetDomain() string

GetDomain returns the allowed redirect url associated with the client.

func (OAuthClient) GetID

func (o OAuthClient) GetID() string

GetID returns the clients id.

func (OAuthClient) GetSecret

func (o OAuthClient) GetSecret() string

GetSecret returns the clients secret.

func (OAuthClient) GetUserID

func (o OAuthClient) GetUserID() string

GetUserID returns the owners' user id.

type OAuthClients

type OAuthClients interface {
	// Get returns the OAuthClient associated with the provided id.
	Get(ctx context.Context, id uuid.UUID) (OAuthClient, error)

	// Create creates a new OAuthClient.
	Create(ctx context.Context, client OAuthClient) error

	// Update modifies information for the provided OAuthClient.
	Update(ctx context.Context, client OAuthClient) error

	// Delete deletes the identified client from the database.
	Delete(ctx context.Context, id uuid.UUID) error
}

OAuthClients defines an interface for creating, updating, and obtaining information about oauth clients known to our system.

type OAuthCode

type OAuthCode struct {
	ClientID        uuid.UUID
	UserID          uuid.UUID
	Scope           string
	RedirectURL     string
	Challenge       string
	ChallengeMethod string
	Code            string
	CreatedAt       time.Time
	ExpiresAt       time.Time
	ClaimedAt       *time.Time
}

OAuthCode represents a code stored within our database.

type OAuthCodes

type OAuthCodes interface {
	// Get retrieves the OAuthCode for the specified code. Implementations should only return unexpired, unclaimed
	// codes. Once a code has been claimed, it should be marked as such to prevent future calls from exchanging the
	// value for an access tokens.
	Get(ctx context.Context, code string) (OAuthCode, error)

	// Create creates a new OAuthCode.
	Create(ctx context.Context, code OAuthCode) error

	// Claim marks that the provided code has been claimed and should not be issued to another caller.
	Claim(ctx context.Context, code string) error
}

OAuthCodes defines a set of operations allowed to be performed against oauth codes.

type OAuthToken

type OAuthToken struct {
	ClientID  uuid.UUID
	UserID    uuid.UUID
	Scope     string
	Kind      OAuthTokenKind
	Token     string
	CreatedAt time.Time
	ExpiresAt time.Time
}

OAuthToken represents a token stored within our database (either access / refresh).

type OAuthTokenKind

type OAuthTokenKind int8

OAuthTokenKind defines an enumeration of different types of supported tokens.

type OAuthTokens

type OAuthTokens interface {
	// Get retrieves the OAuthToken for the specified kind and token value. This can be used to look up either refresh
	// or access tokens that have not expired.
	Get(ctx context.Context, kind OAuthTokenKind, token string) (OAuthToken, error)

	// Create creates a new OAuthToken. If the token already exists, no value is modified and nil is returned.
	Create(ctx context.Context, token OAuthToken) error
}

OAuthTokens defines a set of operations that ca be performed against oauth tokens.

Jump to

Keyboard shortcuts

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