Documentation
¶
Index ¶
- Constants
- func GenerateClientID() (string, error)
- func GenerateCodeChallenge(codeVerifier string) string
- func GetOAuthClientID(c echo.Context) string
- func GetOAuthScope(c echo.Context) string
- func GetOAuthUserID(c echo.Context) model_db.BinaryUUID
- func GetUserIDFromSession(sess *sessions.Session) (string, bool)
- func HasScope(c echo.Context, requiredScope string) bool
- func ValidatePKCE(codeVerifier, codeChallenge, method string) bool
- type BunClientStore
- func (s *BunClientStore) Create(ctx context.Context, client *OAuthClient) error
- func (s *BunClientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error)
- func (s *BunClientStore) GetClientName(ctx context.Context, clientID string) (string, error)
- func (s *BunClientStore) GetRedirectURIs(ctx context.Context, clientID string) ([]string, error)
- func (s *BunClientStore) ValidateRedirectURI(ctx context.Context, clientID, redirectURI string) error
- type BunTokenStore
- func (s *BunTokenStore) Create(ctx context.Context, info oauth2.TokenInfo) error
- func (s *BunTokenStore) CreateWithPKCE(ctx context.Context, info oauth2.TokenInfo, ...) error
- func (s *BunTokenStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error)
- func (s *BunTokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error)
- func (s *BunTokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error)
- func (s *BunTokenStore) GetClientByCode(ctx context.Context, code string) (clientID, userID, redirectURI, scope string, err error)
- func (s *BunTokenStore) GetPKCEByCode(ctx context.Context, code string) (codeChallenge, codeChallengeMethod string, err error)
- func (s *BunTokenStore) RemoveByAccess(ctx context.Context, access string) error
- func (s *BunTokenStore) RemoveByCode(ctx context.Context, code string) error
- func (s *BunTokenStore) RemoveByRefresh(ctx context.Context, refresh string) error
- func (s *BunTokenStore) UpdateCodeToToken(ctx context.Context, code string, info oauth2.TokenInfo) error
- type Config
- type OAuthClient
- type OAuthToken
- type RegisterClientRequest
- type RegisterClientResponse
- type Server
- func (s *Server) AuthorizeHandler(c echo.Context) error
- func (s *Server) AuthorizePageHandler(c echo.Context) error
- func (s *Server) BearerAuthMiddleware() echo.MiddlewareFunc
- func (s *Server) GetClientStore() *BunClientStore
- func (s *Server) GetConfig() Config
- func (s *Server) GetManager() *manage.Manager
- func (s *Server) GetServer() *server.Server
- func (s *Server) GetTokenStore() *BunTokenStore
- func (s *Server) Metadata() map[string]any
- func (s *Server) MetadataHandler(c echo.Context) error
- func (s *Server) RegisterClient(ctx context.Context, req RegisterClientRequest) (*RegisterClientResponse, error)
- func (s *Server) RegisterHandler(c echo.Context) error
- func (s *Server) TokenHandler(c echo.Context) error
Constants ¶
View Source
const ( ContextKeyUserID = "oauth_user_id" ContextKeyClientID = "oauth_client_id" ContextKeyScope = "oauth_scope" )
Variables ¶
This section is empty.
Functions ¶
func GenerateClientID ¶
func GenerateCodeChallenge ¶
func GetOAuthClientID ¶
func GetOAuthScope ¶
func GetOAuthUserID ¶
func GetOAuthUserID(c echo.Context) model_db.BinaryUUID
func ValidatePKCE ¶
Types ¶
type BunClientStore ¶
type BunClientStore struct {
// contains filtered or unexported fields
}
func NewBunClientStore ¶
func NewBunClientStore(db *bun.DB) *BunClientStore
func (*BunClientStore) Create ¶
func (s *BunClientStore) Create(ctx context.Context, client *OAuthClient) error
func (*BunClientStore) GetByID ¶
func (s *BunClientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error)
func (*BunClientStore) GetClientName ¶
func (*BunClientStore) GetRedirectURIs ¶
func (*BunClientStore) ValidateRedirectURI ¶
func (s *BunClientStore) ValidateRedirectURI(ctx context.Context, clientID, redirectURI string) error
type BunTokenStore ¶
type BunTokenStore struct {
// contains filtered or unexported fields
}
func NewBunTokenStore ¶
func NewBunTokenStore(db *bun.DB) *BunTokenStore
func (*BunTokenStore) CreateWithPKCE ¶
func (*BunTokenStore) GetByAccess ¶
func (*BunTokenStore) GetByRefresh ¶
func (*BunTokenStore) GetClientByCode ¶
func (*BunTokenStore) GetPKCEByCode ¶
func (*BunTokenStore) RemoveByAccess ¶
func (s *BunTokenStore) RemoveByAccess(ctx context.Context, access string) error
func (*BunTokenStore) RemoveByCode ¶
func (s *BunTokenStore) RemoveByCode(ctx context.Context, code string) error
func (*BunTokenStore) RemoveByRefresh ¶
func (s *BunTokenStore) RemoveByRefresh(ctx context.Context, refresh string) error
func (*BunTokenStore) UpdateCodeToToken ¶
type Config ¶
type Config struct {
Issuer string
AuthCodeExpiry time.Duration
AccessTokenExpiry time.Duration
RefreshTokenExpiry time.Duration
AllowedResponseTypes []oauth2.ResponseType
AllowedGrantTypes []oauth2.GrantType
}
func DefaultConfig ¶
type OAuthClient ¶
type OAuthClient struct {
bun.BaseModel `bun:"table:oauth_clients"`
ID string `bun:"id,pk"`
SecretHash []byte `bun:"secret_hash"`
Name string `bun:"name,notnull"`
RedirectURIs string `bun:"redirect_uris,notnull"`
UserID *model_db.BinaryUUID `bun:"user_id"`
CreatedAt time.Time `bun:"created_at,nullzero,notnull"`
}
type OAuthToken ¶
type OAuthToken struct {
bun.BaseModel `bun:"table:oauth_tokens"`
Code string `bun:"code,pk"`
Access string `bun:"access"`
Refresh string `bun:"refresh"`
ClientID string `bun:"client_id,notnull"`
UserID model_db.BinaryUUID `bun:"user_id,notnull"`
RedirectURI string `bun:"redirect_uri"`
Scope string `bun:"scope"`
CodeChallenge string `bun:"code_challenge"`
CodeChallengeMethod string `bun:"code_challenge_method"`
CodeExpiresAt *time.Time `bun:"code_expires_at"`
AccessExpiresAt *time.Time `bun:"access_expires_at"`
RefreshExpiresAt *time.Time `bun:"refresh_expires_at"`
CreatedAt time.Time `bun:"created_at,nullzero,notnull"`
}
type RegisterClientRequest ¶
type RegisterClientResponse ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) BearerAuthMiddleware ¶
func (s *Server) BearerAuthMiddleware() echo.MiddlewareFunc
func (*Server) GetClientStore ¶
func (s *Server) GetClientStore() *BunClientStore
func (*Server) GetManager ¶
func (*Server) GetTokenStore ¶
func (s *Server) GetTokenStore() *BunTokenStore
func (*Server) RegisterClient ¶
func (s *Server) RegisterClient(ctx context.Context, req RegisterClientRequest) (*RegisterClientResponse, error)
Click to show internal directories.
Click to hide internal directories.