Documentation
¶
Index ¶
- Constants
- type Factory
- type RefreshToken
- type Storer
- func (s Storer) CreateToken(ctx context.Context, token tokens.RefreshToken) error
- func (s Storer) GetToken(ctx context.Context, token string) (tokens.RefreshToken, error)
- func (s Storer) GetTokensByProfileID(ctx context.Context, profileID string, since, before time.Time) ([]tokens.RefreshToken, error)
- func (s Storer) UpdateTokens(ctx context.Context, change tokens.RefreshTokenChange) error
- func (s Storer) UseToken(ctx context.Context, id string) error
Constants ¶
const (
TestConnStringEnvVar = "PG_TEST_DB"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
func NewFactory ¶
func (*Factory) TeardownStorer ¶
type RefreshToken ¶
type RefreshToken struct { ID string CreatedAt time.Time CreatedFrom string Scopes pqarrays.StringArray ProfileID string ClientID string Revoked bool Used bool }
RefreshToken represents a refresh token that can be used to obtain a new access token.
func (RefreshToken) GetSQLTableName ¶
func (t RefreshToken) GetSQLTableName() string
GetSQLTableName returns the name of the PostgreSQL table RefreshTokens will be stored in. It is required for use with pan.
type Storer ¶
type Storer struct {
// contains filtered or unexported fields
}
Storer is an implementation of the Storer interface that is production quality and backed by a PostgreSQL database.
func (Storer) CreateToken ¶
CreateToken inserts the passed tokens.RefreshToken into Storer. If a tokens.RefreshToken with the same ID already exists in Storer, an ErrTokenAlreadyExists error will be returned, and the tokens.RefreshToken will not be inserted.
func (Storer) GetToken ¶
GetToken retrieves the tokens.RefreshToken with an ID matching `token` from Storer. If no tokens.RefreshToken has that ID, an ErrTokenNotFound error is returned.
func (Storer) GetTokensByProfileID ¶
func (s Storer) GetTokensByProfileID(ctx context.Context, profileID string, since, before time.Time) ([]tokens.RefreshToken, error)
GetTokensByProfileID retrieves up to NumTokenResults tokens.RefreshTokens from Storer. Only tokens.RefreshTokens with a ProfileID property matching `profileID` will be returned. If `since` is non-empty, only tokens.RefreshTokens with a CreatedAt property that is after `since` will be returned. If `before` is non-empty, only tokens.RefreshTokens with a CreatedAt property that is before `before` will be returned. tokens.RefreshTokens will be sorted by their CreatedAt property, with the most recent coming first.
func (Storer) UpdateTokens ¶
UpdateTokens applies `change` to all the tokens.RefreshTokens in Storer that match the ID, ProfileID, or ClientID constraints of `change`.