Documentation
¶
Index ¶
- type AuthorizationCode
- type Client
- type MemoryStorage
- func (s *MemoryStorage) CreateClient(ctx context.Context, client *Client) error
- func (s *MemoryStorage) DeleteAuthorizationCode(ctx context.Context, code string) error
- func (s *MemoryStorage) DeleteClient(ctx context.Context, clientID string) error
- func (s *MemoryStorage) DeleteToken(ctx context.Context, accessToken string) error
- func (s *MemoryStorage) DeleteTokensByClientID(ctx context.Context, clientID string) error
- func (s *MemoryStorage) GetAuthorizationCode(ctx context.Context, code string) (*AuthorizationCode, error)
- func (s *MemoryStorage) GetClient(ctx context.Context, clientID string) (*Client, error)
- func (s *MemoryStorage) GetToken(ctx context.Context, accessToken string) (*Token, error)
- func (s *MemoryStorage) SaveAuthorizationCode(ctx context.Context, code *AuthorizationCode) error
- func (s *MemoryStorage) SaveToken(ctx context.Context, token *Token) error
- func (s *MemoryStorage) UpdateClient(ctx context.Context, client *Client) error
- type RedisStorage
- func (s *RedisStorage) CreateClient(ctx context.Context, client *Client) error
- func (s *RedisStorage) DeleteAuthorizationCode(ctx context.Context, code string) error
- func (s *RedisStorage) DeleteClient(ctx context.Context, clientID string) error
- func (s *RedisStorage) DeleteToken(ctx context.Context, accessToken string) error
- func (s *RedisStorage) DeleteTokensByClientID(ctx context.Context, clientID string) error
- func (s *RedisStorage) GetAuthorizationCode(ctx context.Context, code string) (*AuthorizationCode, error)
- func (s *RedisStorage) GetClient(ctx context.Context, clientID string) (*Client, error)
- func (s *RedisStorage) GetToken(ctx context.Context, accessToken string) (*Token, error)
- func (s *RedisStorage) SaveAuthorizationCode(ctx context.Context, code *AuthorizationCode) error
- func (s *RedisStorage) SaveToken(ctx context.Context, token *Token) error
- func (s *RedisStorage) UpdateClient(ctx context.Context, client *Client) error
- type Store
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthorizationCode ¶
type AuthorizationCode struct {
Code string `json:"code"`
ClientID string `json:"client_id"`
RedirectURI string `json:"redirect_uri"`
Scope []string `json:"scope"`
ExpiresAt int64 `json:"expires_at"`
CreatedAt int64 `json:"created_at"`
}
AuthorizationCode represents an authorization code
type Client ¶
type Client struct {
ID string `json:"client_id"`
Secret string `json:"client_secret"`
RedirectURIs []string `json:"redirect_uris"`
GrantTypes []string `json:"grant_types"`
ResponseTypes []string `json:"response_types"`
TokenAuthMethod string `json:"token_endpoint_auth_method"`
Scope string `json:"scope"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
Client represents an OAuth2 client
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage implements the Store interface using in-memory storage
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
NewMemoryStorage creates a new memory storage instance
func (*MemoryStorage) CreateClient ¶
func (s *MemoryStorage) CreateClient(ctx context.Context, client *Client) error
CreateClient creates a new client
func (*MemoryStorage) DeleteAuthorizationCode ¶
func (s *MemoryStorage) DeleteAuthorizationCode(ctx context.Context, code string) error
DeleteAuthorizationCode deletes an authorization code
func (*MemoryStorage) DeleteClient ¶
func (s *MemoryStorage) DeleteClient(ctx context.Context, clientID string) error
DeleteClient deletes a client
func (*MemoryStorage) DeleteToken ¶
func (s *MemoryStorage) DeleteToken(ctx context.Context, accessToken string) error
DeleteToken deletes a token
func (*MemoryStorage) DeleteTokensByClientID ¶
func (s *MemoryStorage) DeleteTokensByClientID(ctx context.Context, clientID string) error
DeleteTokensByClientID deletes all tokens for a client
func (*MemoryStorage) GetAuthorizationCode ¶
func (s *MemoryStorage) GetAuthorizationCode(ctx context.Context, code string) (*AuthorizationCode, error)
GetAuthorizationCode retrieves an authorization code
func (*MemoryStorage) SaveAuthorizationCode ¶
func (s *MemoryStorage) SaveAuthorizationCode(ctx context.Context, code *AuthorizationCode) error
SaveAuthorizationCode saves an authorization code
func (*MemoryStorage) SaveToken ¶
func (s *MemoryStorage) SaveToken(ctx context.Context, token *Token) error
SaveToken saves a token
func (*MemoryStorage) UpdateClient ¶
func (s *MemoryStorage) UpdateClient(ctx context.Context, client *Client) error
UpdateClient updates an existing client
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
RedisStorage implements the Store interface using Redis
func NewRedisStorage ¶
func NewRedisStorage(clusterType, addr, masterName string, username, password string, db int) (*RedisStorage, error)
NewRedisStorage creates a new Redis storage instance
func (*RedisStorage) CreateClient ¶
func (s *RedisStorage) CreateClient(ctx context.Context, client *Client) error
CreateClient creates a new client
func (*RedisStorage) DeleteAuthorizationCode ¶
func (s *RedisStorage) DeleteAuthorizationCode(ctx context.Context, code string) error
DeleteAuthorizationCode deletes an authorization code
func (*RedisStorage) DeleteClient ¶
func (s *RedisStorage) DeleteClient(ctx context.Context, clientID string) error
DeleteClient deletes a client
func (*RedisStorage) DeleteToken ¶
func (s *RedisStorage) DeleteToken(ctx context.Context, accessToken string) error
DeleteToken deletes a token
func (*RedisStorage) DeleteTokensByClientID ¶
func (s *RedisStorage) DeleteTokensByClientID(ctx context.Context, clientID string) error
DeleteTokensByClientID deletes all tokens for a client
func (*RedisStorage) GetAuthorizationCode ¶
func (s *RedisStorage) GetAuthorizationCode(ctx context.Context, code string) (*AuthorizationCode, error)
GetAuthorizationCode retrieves an authorization code
func (*RedisStorage) SaveAuthorizationCode ¶
func (s *RedisStorage) SaveAuthorizationCode(ctx context.Context, code *AuthorizationCode) error
SaveAuthorizationCode saves an authorization code
func (*RedisStorage) SaveToken ¶
func (s *RedisStorage) SaveToken(ctx context.Context, token *Token) error
SaveToken saves a token
func (*RedisStorage) UpdateClient ¶
func (s *RedisStorage) UpdateClient(ctx context.Context, client *Client) error
UpdateClient updates an existing client
type Store ¶
type Store interface {
GetClient(ctx context.Context, clientID string) (*Client, error)
CreateClient(ctx context.Context, client *Client) error
UpdateClient(ctx context.Context, client *Client) error
DeleteClient(ctx context.Context, clientID string) error
SaveAuthorizationCode(ctx context.Context, code *AuthorizationCode) error
GetAuthorizationCode(ctx context.Context, code string) (*AuthorizationCode, error)
DeleteAuthorizationCode(ctx context.Context, code string) error
SaveToken(ctx context.Context, token *Token) error
GetToken(ctx context.Context, accessToken string) (*Token, error)
DeleteToken(ctx context.Context, accessToken string) error
DeleteTokensByClientID(ctx context.Context, clientID string) error
}
Store defines the interface for OAuth2 data storage
type Token ¶
type Token struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
RefreshToken string `json:"refresh_token,omitempty"`
ClientID string `json:"client_id"`
Scope []string `json:"scope"`
ExpiresAt int64 `json:"expires_at"`
CreatedAt int64 `json:"created_at"`
}
Token represents an OAuth2 token