Documentation
¶
Overview ¶
Package auth is a generated GoMock package.
Index ¶
- Constants
- type AuthRouter
- type FlowCookies
- func (f *FlowCookies) Delete(c *gin.Context, prefix, id string)
- func (f *FlowCookies) DeleteAuthorizeRequest(c *gin.Context, arID string)
- func (f *FlowCookies) Get(c *gin.Context, prefix, id string) (string, bool)
- func (f *FlowCookies) HasAuthorizeRequest(c *gin.Context, arID string) bool
- func (f *FlowCookies) Set(c *gin.Context, prefix, id, value string) error
- func (f *FlowCookies) SetAuthorizeRequest(c *gin.Context, arID string) error
- type MockProvider
- func (m *MockProvider) AuthCodeURL(state string) (string, error)
- func (m *MockProvider) AuthURL() string
- func (m *MockProvider) Authorization(ctx context.Context, token *oauth2.Token) (bool, string, map[string]any, error)
- func (m *MockProvider) EXPECT() *MockProviderMockRecorder
- func (m *MockProvider) Exchange(c *gin.Context, state string) (*oauth2.Token, error)
- func (m *MockProvider) Name() string
- func (m *MockProvider) RedirectURL() string
- func (m *MockProvider) Type() string
- type MockProviderMockRecorder
- func (mr *MockProviderMockRecorder) AuthCodeURL(state any) *gomock.Call
- func (mr *MockProviderMockRecorder) AuthURL() *gomock.Call
- func (mr *MockProviderMockRecorder) Authorization(ctx, token any) *gomock.Call
- func (mr *MockProviderMockRecorder) Exchange(c, state any) *gomock.Call
- func (mr *MockProviderMockRecorder) Name() *gomock.Call
- func (mr *MockProviderMockRecorder) RedirectURL() *gomock.Call
- func (mr *MockProviderMockRecorder) Type() *gomock.Call
- type Provider
- func NewGithubProvider(oauthEndpoint, apiURL, clientID, clientSecret, externalURL string, ...) (Provider, error)
- func NewGoogleProvider(externalURL, clientID, clientSecret string, allowedUsers []string, ...) (Provider, error)
- func NewOIDCProvider(configurationURL string, scopes []string, userIDField string, ...) (Provider, error)
Constants ¶
const ( LoginEndpoint = "/.auth/login" LogoutEndpoint = "/.auth/logout" GoogleAuthEndpoint = "/.auth/google" GoogleCallbackEndpoint = "/.auth/google/callback" GitHubAuthEndpoint = "/.auth/github" GitHubCallbackEndpoint = "/.auth/github/callback" OIDCAuthEndpoint = "/.auth/oidc" OIDCCallbackEndpoint = "/.auth/oidc/callback" PasswordProvider = "password" PasswordUserID = "password_user" SessionKeyAuthorized = "authorized" SessionKeyUserID = "user_id" SessionKeyUserInfo = "user_info" )
const FlowMaxAge = 600
FlowMaxAge bounds how long an unfinished login or authorization request stays valid, in seconds. It matches the session cookie.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthRouter ¶
type AuthRouter struct {
// contains filtered or unexported fields
}
func NewAuthRouter ¶
func NewAuthRouter(passwordHash []string, noProviderAutoSelect bool, userInfoFields []string, flows *FlowCookies, providers ...Provider) (*AuthRouter, error)
func (*AuthRouter) Flows ¶ added in v2.10.5
func (a *AuthRouter) Flows() *FlowCookies
Flows returns the per-flow cookie store, which the IdP router shares.
func (*AuthRouter) RequireAuth ¶
func (a *AuthRouter) RequireAuth() gin.HandlerFunc
func (*AuthRouter) SetupRoutes ¶
func (a *AuthRouter) SetupRoutes(router gin.IRouter)
type FlowCookies ¶ added in v2.10.5
type FlowCookies struct {
// contains filtered or unexported fields
}
FlowCookies keeps the state of each in-flight login or authorization request in a cookie of its own, named after the flow.
The alternative, one shared session cookie holding every flow's state, breaks as soon as a client opens several flows at once: each response rewrites the whole cookie, the browser keeps only the last, and every other flow fails its state check. Claude's desktop app does exactly that, starting one flow per configured MCP server at the same moment. With one cookie per flow, concurrent flows never write to the same cookie.
Values are HMAC-signed, and the cookie name is covered by the signature, so a cookie issued for one flow cannot be replayed as another's.
func NewFlowCookies ¶ added in v2.10.5
func NewFlowCookies(secret []byte, secure bool) *FlowCookies
func (*FlowCookies) Delete ¶ added in v2.10.5
func (f *FlowCookies) Delete(c *gin.Context, prefix, id string)
Delete ends flow id, so it cannot be completed twice.
func (*FlowCookies) DeleteAuthorizeRequest ¶ added in v2.10.5
func (f *FlowCookies) DeleteAuthorizeRequest(c *gin.Context, arID string)
func (*FlowCookies) Get ¶ added in v2.10.5
Get returns the value stored for flow id, and false if this browser did not start that flow or it has expired.
func (*FlowCookies) HasAuthorizeRequest ¶ added in v2.10.5
func (f *FlowCookies) HasAuthorizeRequest(c *gin.Context, arID string) bool
func (*FlowCookies) Set ¶ added in v2.10.5
func (f *FlowCookies) Set(c *gin.Context, prefix, id, value string) error
Set starts tracking flow id under prefix, remembering value with it.
func (*FlowCookies) SetAuthorizeRequest ¶ added in v2.10.5
func (f *FlowCookies) SetAuthorizeRequest(c *gin.Context, arID string) error
SetAuthorizeRequest, HasAuthorizeRequest and DeleteAuthorizeRequest track a pending authorization request for the IdP router.
type MockProvider ¶
type MockProvider struct {
// contains filtered or unexported fields
}
MockProvider is a mock of Provider interface.
func NewMockProvider ¶
func NewMockProvider(ctrl *gomock.Controller) *MockProvider
NewMockProvider creates a new mock instance.
func (*MockProvider) AuthCodeURL ¶
func (m *MockProvider) AuthCodeURL(state string) (string, error)
AuthCodeURL mocks base method.
func (*MockProvider) Authorization ¶
func (m *MockProvider) Authorization(ctx context.Context, token *oauth2.Token) (bool, string, map[string]any, error)
Authorization mocks base method.
func (*MockProvider) EXPECT ¶
func (m *MockProvider) EXPECT() *MockProviderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockProvider) RedirectURL ¶
func (m *MockProvider) RedirectURL() string
RedirectURL mocks base method.
type MockProviderMockRecorder ¶
type MockProviderMockRecorder struct {
// contains filtered or unexported fields
}
MockProviderMockRecorder is the mock recorder for MockProvider.
func (*MockProviderMockRecorder) AuthCodeURL ¶
func (mr *MockProviderMockRecorder) AuthCodeURL(state any) *gomock.Call
AuthCodeURL indicates an expected call of AuthCodeURL.
func (*MockProviderMockRecorder) AuthURL ¶
func (mr *MockProviderMockRecorder) AuthURL() *gomock.Call
AuthURL indicates an expected call of AuthURL.
func (*MockProviderMockRecorder) Authorization ¶
func (mr *MockProviderMockRecorder) Authorization(ctx, token any) *gomock.Call
Authorization indicates an expected call of Authorization.
func (*MockProviderMockRecorder) Exchange ¶
func (mr *MockProviderMockRecorder) Exchange(c, state any) *gomock.Call
Exchange indicates an expected call of Exchange.
func (*MockProviderMockRecorder) Name ¶
func (mr *MockProviderMockRecorder) Name() *gomock.Call
Name indicates an expected call of Name.
func (*MockProviderMockRecorder) RedirectURL ¶
func (mr *MockProviderMockRecorder) RedirectURL() *gomock.Call
RedirectURL indicates an expected call of RedirectURL.
func (*MockProviderMockRecorder) Type ¶
func (mr *MockProviderMockRecorder) Type() *gomock.Call
Type indicates an expected call of Type.
type Provider ¶
type Provider interface {
Name() string
Type() string
RedirectURL() string
AuthURL() string
AuthCodeURL(state string) (string, error)
Exchange(c *gin.Context, state string) (*oauth2.Token, error)
Authorization(ctx context.Context, token *oauth2.Token) (bool, string, map[string]any, error)
}