Documentation ¶
Index ¶
- func ConnectToMongo(cfg *Config) (*mgo.Database, error)
- func ConnectionURI(cfg *Config) string
- type Config
- type MongoStore
- func (m *MongoStore) Authenticate(ctx context.Context, username string, secret string) error
- func (m MongoStore) AuthenticateClient(id string, secret []byte) (*client.Client, error)
- func (m *MongoStore) AuthenticateUserByUsername(ctx context.Context, username string, secret string) (*user.User, error)
- func (m *MongoStore) Close()
- func (m *MongoStore) CreateAccessTokenSession(ctx context.Context, signature string, request fosite.Requester) (err error)
- func (m *MongoStore) CreateAuthorizeCodeSession(ctx context.Context, code string, request fosite.Requester) (err error)
- func (m *MongoStore) CreateClient(c *client.Client) error
- func (m *MongoStore) CreateImplicitAccessTokenSession(ctx context.Context, token string, request fosite.Requester) (err error)
- func (m *MongoStore) CreateOpenIDConnectSession(ctx context.Context, authorizeCode string, requester fosite.Requester) (err error)
- func (m *MongoStore) CreateRefreshTokenSession(ctx context.Context, signature string, request fosite.Requester) (err error)
- func (m *MongoStore) DeleteAccessTokenSession(ctx context.Context, signature string) (err error)
- func (m *MongoStore) DeleteAuthorizeCodeSession(ctx context.Context, code string) (err error)
- func (m *MongoStore) DeleteClient(id string) error
- func (m *MongoStore) DeleteOpenIDConnectSession(ctx context.Context, authorizeCode string) (err error)
- func (m *MongoStore) DeleteRefreshTokenSession(ctx context.Context, signature string) (err error)
- func (m MongoStore) GetAccessTokenSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error)
- func (m MongoStore) GetAuthorizeCodeSession(ctx context.Context, code string, session fosite.Session) (request fosite.Requester, err error)
- func (m MongoStore) GetClient(ctx context.Context, id string) (fosite.Client, error)
- func (m MongoStore) GetClients() (clients map[string]client.Client, err error)
- func (m *MongoStore) GetOpenIDConnectSession(ctx context.Context, authorizeCode string, requester fosite.Requester) (req fosite.Requester, err error)
- func (m *MongoStore) GetRefreshTokenSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error)
- func (m *MongoStore) PersistAuthorizeCodeGrantSession(ctx context.Context, authorizeCode, accessSignature, refreshSignature string, ...) error
- func (m *MongoStore) PersistRefreshTokenGrantSession(ctx context.Context, ...) (err error)
- func (m *MongoStore) RevokeAccessToken(ctx context.Context, requestID string) error
- func (m *MongoStore) RevokeRefreshToken(ctx context.Context, requestID string) error
- func (m *MongoStore) UpdateClient(c *client.Client) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectToMongo ¶
ConnectToMongo returns a connection to mongo.
func ConnectionURI ¶
ConnectionURI generates a formatted Mongo Connection URL
Types ¶
type Config ¶
type Config struct { // Default connection settings Hostname string Hostnames []string Port uint16 // 0 to 65,535 DatabaseName string // Credential Access Username string Password string // Replica Set Replset string // Timeout specified in seconds. Timeout uint }
Config provides a way to define the specific pieces that make up a mongo connection
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a configuration for a locally hosted, unauthenticated mongo
type MongoStore ¶
type MongoStore struct { // DB is the Mongo connection that holds the base session that can be copied and closed. DB *mgo.Database Hasher fosite.Hasher Clients *client.MongoManager Requests *request.MongoManager Users *user.MongoManager // Cache Stores // - *cache.MemoryManager // - *cache.MongoManager // - *cache.RedisManager Cache *cache.MongoManager }
MongoStore composes all stores into the one datastore to rule them all
func NewDefaultMongoStore ¶
func NewDefaultMongoStore() (*MongoStore, error)
NewDefaultMongoStore returns a MongoStore configured with the default mongo configuration and default hasher.
func NewExampleMongoStore ¶
func NewExampleMongoStore() *MongoStore
NewExampleMongoStore returns an example mongo store that matches the fosite-example data. If a default unauthenticated mongo database can't be found at localhost:27017, it will panic as you've done it wrong.
func NewMongoStore ¶
func NewMongoStore(cfg *Config, hasher fosite.Hasher) (*MongoStore, error)
NewMongoStore allows for custom mongo configuration and custom hashers.
func (*MongoStore) Authenticate ¶
Authenticate checks if supplied user credentials are valid for User Credentials Grant
func (MongoStore) AuthenticateClient ¶
AuthenticateClient checks is supplied client credentials are valid
func (*MongoStore) AuthenticateUserByUsername ¶
func (m *MongoStore) AuthenticateUserByUsername(ctx context.Context, username string, secret string) (*user.User, error)
AuthenticateUserByUsername checks if supplied user credentials are valid
func (*MongoStore) Close ¶
func (m *MongoStore) Close()
Close ensures that each endpoint has it's connection closed properly.
func (*MongoStore) CreateAccessTokenSession ¶
func (m *MongoStore) CreateAccessTokenSession(ctx context.Context, signature string, request fosite.Requester) (err error)
CreateAccessTokenSession creates a new session for an Access Token in mongo
func (*MongoStore) CreateAuthorizeCodeSession ¶
func (m *MongoStore) CreateAuthorizeCodeSession(ctx context.Context, code string, request fosite.Requester) (err error)
CreateAuthorizeCodeSession creates a new session for an authorize code grant in mongo
func (*MongoStore) CreateClient ¶
func (m *MongoStore) CreateClient(c *client.Client) error
CreateClient adds a new OAuth2.0 Client to the client store.
func (*MongoStore) CreateImplicitAccessTokenSession ¶
func (m *MongoStore) CreateImplicitAccessTokenSession(ctx context.Context, token string, request fosite.Requester) (err error)
CreateImplicitAccessTokenSession stores an implicit access token based session in mongo
func (*MongoStore) CreateOpenIDConnectSession ¶
func (m *MongoStore) CreateOpenIDConnectSession(ctx context.Context, authorizeCode string, requester fosite.Requester) (err error)
CreateOpenIDConnectSession creates an open id connect session for a given authorize code in mongo. This is relevant for explicit open id connect flow.
func (*MongoStore) CreateRefreshTokenSession ¶
func (m *MongoStore) CreateRefreshTokenSession(ctx context.Context, signature string, request fosite.Requester) (err error)
CreateRefreshTokenSession stores a new Refresh Token Session in mongo
func (*MongoStore) DeleteAccessTokenSession ¶
func (m *MongoStore) DeleteAccessTokenSession(ctx context.Context, signature string) (err error)
DeleteAccessTokenSession removes an Access Tokens current session from mongo
func (*MongoStore) DeleteAuthorizeCodeSession ¶
func (m *MongoStore) DeleteAuthorizeCodeSession(ctx context.Context, code string) (err error)
DeleteAuthorizeCodeSession removes an authorize code session from mongo
func (*MongoStore) DeleteClient ¶
func (m *MongoStore) DeleteClient(id string) error
DeleteClient removes an OAuth 2.0 Client from the client store
func (*MongoStore) DeleteOpenIDConnectSession ¶
func (m *MongoStore) DeleteOpenIDConnectSession(ctx context.Context, authorizeCode string) (err error)
DeleteOpenIDConnectSession removes an open id connect session from mongo.
func (*MongoStore) DeleteRefreshTokenSession ¶
func (m *MongoStore) DeleteRefreshTokenSession(ctx context.Context, signature string) (err error)
DeleteRefreshTokenSession removes a Refresh Token that has been previously stored in mongo
func (MongoStore) GetAccessTokenSession ¶
func (m MongoStore) GetAccessTokenSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error)
GetAccessTokenSession returns a session if it can be found by signature in mongo
func (MongoStore) GetAuthorizeCodeSession ¶
func (m MongoStore) GetAuthorizeCodeSession(ctx context.Context, code string, session fosite.Session) (request fosite.Requester, err error)
GetAuthorizeCodeSession finds an authorize code grant session in mongo
func (MongoStore) GetClients ¶
func (m MongoStore) GetClients() (clients map[string]client.Client, err error)
GetClients returns a map of clients mapped by client ID
func (*MongoStore) GetOpenIDConnectSession ¶
func (m *MongoStore) GetOpenIDConnectSession(ctx context.Context, authorizeCode string, requester fosite.Requester) (req fosite.Requester, err error)
GetOpenIDConnectSession gets a session based off the Authorize Code and returns a fosite.Requester which contains a session or an error.
func (*MongoStore) GetRefreshTokenSession ¶
func (m *MongoStore) GetRefreshTokenSession(ctx context.Context, signature string, session fosite.Session) (request fosite.Requester, err error)
GetRefreshTokenSession returns a Refresh Token Session that's been previously stored in mongo
func (*MongoStore) PersistAuthorizeCodeGrantSession ¶
func (m *MongoStore) PersistAuthorizeCodeGrantSession(ctx context.Context, authorizeCode, accessSignature, refreshSignature string, request fosite.Requester) error
PersistAuthorizeCodeGrantSession creates an Authorise Code Grant session in mongo
func (*MongoStore) PersistRefreshTokenGrantSession ¶
func (m *MongoStore) PersistRefreshTokenGrantSession(ctx context.Context, requestRefreshSignature, accessSignature, refreshSignature string, request fosite.Requester) (err error)
PersistRefreshTokenGrantSession stores a refresh token grant session in mongo
func (*MongoStore) RevokeAccessToken ¶
func (m *MongoStore) RevokeAccessToken(ctx context.Context, requestID string) error
RevokeAccessToken finds a token stored in cache based on request ID and deletes the session by signature.
func (*MongoStore) RevokeRefreshToken ¶
func (m *MongoStore) RevokeRefreshToken(ctx context.Context, requestID string) error
RevokeRefreshToken finds a token stored in cache based on request ID and deletes the session by signature.
func (*MongoStore) UpdateClient ¶
func (m *MongoStore) UpdateClient(c *client.Client) error
UpdateClient updates an OAuth 2.0 Client record. This is done using the equivalent of an object replace.