Documentation ¶
Index ¶
- type ClientAuthRepository
- type MongoDBClientAuthRepository
- func (m *MongoDBClientAuthRepository) Delete(clientID, code string) error
- func (m *MongoDBClientAuthRepository) GetWithCode(clientID, code string) (*oauth2.ClientAuth, error)
- func (m *MongoDBClientAuthRepository) GetWithUserID(clientID, userID string) (*oauth2.ClientAuth, error)
- func (m *MongoDBClientAuthRepository) Save(clientAuth *oauth2.ClientAuth) (*oauth2.ClientAuth, error)
- type MongoDBTokenRepository
- type TokenRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientAuthRepository ¶
type ClientAuthRepository interface { // GetWithCode looks up a ClientAuth by the clientID and the authorization code. GetWithCode(clientID, code string) (*oauth2.ClientAuth, error) // GetWithUserID looks up a ClientAuth by the clientID and the userID of the user that authorized that client. GetWithUserID(clientID, userID string) (*oauth2.ClientAuth, error) // Save saves the new or updated ClientAuth. Save(clientAuth *oauth2.ClientAuth) (*oauth2.ClientAuth, error) // Delete removes a ClientAuth for a client and auth code. Delete(clientID, code string) error }
ClientAuthRepository defines the interface for accessing the ClientAuth in a persistence.
type MongoDBClientAuthRepository ¶
type MongoDBClientAuthRepository struct {
// contains filtered or unexported fields
}
MongoDBClientAuthRepository holds the mongo related collection for the ClientAuthRepository implementation.
func NewDBClientAuthRepository ¶
func NewDBClientAuthRepository(host, dbName, username, password string, clientAuthTTL time.Duration) (*MongoDBClientAuthRepository, func(), error)
NewDBClientAuthRepository creates new ClientAuthRepository that is backed by a Mongodb collection.
func (*MongoDBClientAuthRepository) Delete ¶
func (m *MongoDBClientAuthRepository) Delete(clientID, code string) error
Delete removes the ClientAuth for a client and auth code from mongo db collection.
func (*MongoDBClientAuthRepository) GetWithCode ¶
func (m *MongoDBClientAuthRepository) GetWithCode(clientID, code string) (*oauth2.ClientAuth, error)
GetWithCode retrieves the ClientAuth from mongo db collection.
func (*MongoDBClientAuthRepository) GetWithUserID ¶
func (m *MongoDBClientAuthRepository) GetWithUserID(clientID, userID string) (*oauth2.ClientAuth, error)
GetWithUserID retrieves the ClientAuth for a particular user and client from mongo db collection.
func (*MongoDBClientAuthRepository) Save ¶
func (m *MongoDBClientAuthRepository) Save(clientAuth *oauth2.ClientAuth) (*oauth2.ClientAuth, error)
Save saves new or updated ClientAuth in mongo db collection. The record in mongo is stored with expiration time (TTL) and will be automatically removed by mongo once the expiration time is reached.
type MongoDBTokenRepository ¶
type MongoDBTokenRepository struct {
// contains filtered or unexported fields
}
MongoDBTokenRepository holds mongo related values for TokenRepository implementation.
func NewTokenRepository ¶
func NewTokenRepository(host, dbName, username, password string, tokenTTL time.Duration) (*MongoDBTokenRepository, func(), error)
NewTokenRepository creates new TokenRepository that is backed by mongo. Note that you need to provide a token TTL. Each token entry in mongo is set to expire after this time duration.
func (*MongoDBTokenRepository) GetForClientAndUser ¶
func (m *MongoDBTokenRepository) GetForClientAndUser(clientID, userID string) (*oauth2.AuthToken, error)
GetForClientAndUser retrieves the AuthToken from the backing mongo collection.
func (*MongoDBTokenRepository) GetForRefreshToken ¶
func (m *MongoDBTokenRepository) GetForRefreshToken(refreshToken string) (*oauth2.AuthToken, error)
GetForRefreshToken retrieves the AuthToken identified by its refreshToken from the backing mongo collection.
type TokenRepository ¶
type TokenRepository interface { // GetForClientAndUser retrieves an AuthToken for a particular user and client. GetForClientAndUser(clientID, userID string) (*oauth2.AuthToken, error) // GetForRefreshToken retrieves an AuthToken by its refreshToken value. GetForRefreshToken(refreshToken string) (*oauth2.AuthToken, error) // Save save new AuthToken. Save(token *oauth2.AuthToken) (*oauth2.AuthToken, error) }
TokenRepository defines interface for accessing OAuth2 tokens in a persistence.