Documentation
¶
Index ¶
- Constants
- type Module
- func (m *Module) AuthorizeGETHandler(c *gin.Context)
- func (m *Module) AuthorizePOSTHandler(c *gin.Context)
- func (m *Module) CallbackGETHandler(c *gin.Context)
- func (m *Module) FinalizePOSTHandler(c *gin.Context)
- func (m *Module) OOBTokenGETHandler(c *gin.Context)
- func (m *Module) RouteAuth(...)
- func (m *Module) RouteOAuth(...)
- func (m *Module) SignInGETHandler(c *gin.Context)
- func (m *Module) SignInPOSTHandler(c *gin.Context)
- func (m *Module) TokenPOSTHandler(c *gin.Context)
- func (m *Module) TokenRevokePOSTHandler(c *gin.Context)
- func (m *Module) TwoFactorCodeGETHandler(c *gin.Context)
- func (m *Module) TwoFactorCodePOSTHandler(c *gin.Context)
Constants ¶
const ( AuthSignInPath = "/sign_in" Auth2FAPath = "/2fa" AuthCheckYourEmailPath = "/check_your_email" AuthWaitForApprovalPath = "/wait_for_approval" AuthAccountDisabledPath = "/account_disabled" AuthCallbackPath = "/callback" OauthAuthorizePath = "/authorize" OauthFinalizePath = "/finalize" OauthOOBTokenPath = "/oob" // #nosec G101 else we get a hardcoded credentials warning OauthTokenPath = "/token" // #nosec G101 else we get a hardcoded credentials warning OauthRevokePath = "/revoke" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func New ¶
New returns an Auth module which provides both 'oauth' and 'auth' endpoints.
It is safe to pass a nil idp if oidc is disabled.
func (*Module) AuthorizeGETHandler ¶
AuthorizeGETHandler should be served as GET at https://example.org/oauth/authorize.
The idea here is to present an authorization page to the user, informing them of the scopes the application is requesting, with a button that they have to click to give it permission.
func (*Module) AuthorizePOSTHandler ¶
AuthorizePOSTHandler should be served as POST at https://example.org/oauth/authorize.
At this point we assume that the user has signed in and permitted the app to act on their behalf. We should proceed with the authentication flow and generate an oauth code at the redirect URI.
func (*Module) CallbackGETHandler ¶
CallbackGETHandler parses a token from an external auth provider.
func (*Module) FinalizePOSTHandler ¶
FinalizePOSTHandler registers the user after additional data has been provided
func (*Module) OOBTokenGETHandler ¶
OOBTokenGETHandler parses the OAuth code from the query params and serves a nice little HTML page showing the code.
func (*Module) RouteAuth ¶
func (m *Module) RouteAuth(attachHandler func(method string, path string, f ...gin.HandlerFunc) gin.IRoutes)
RouteAuth routes all paths that should have an 'auth' prefix
func (*Module) RouteOAuth ¶
func (m *Module) RouteOAuth(attachHandler func(method string, path string, f ...gin.HandlerFunc) gin.IRoutes)
RouteOAuth routes all paths that should have an 'oauth' prefix
func (*Module) SignInGETHandler ¶
SignInGETHandler should be served at GET https://example.org/auth/sign_in.
The idea is to present a friendly sign-in page to the user, where they can enter their username and password.
When submitted, the form will POST to the sign- in page, which will be handled by SignInPOSTHandler.
If an idp provider is set, then the user will be redirected to that to do their sign in.
func (*Module) SignInPOSTHandler ¶
SignInPOSTHandler should be served at POST https://example.org/auth/sign_in.
The handler will check the submitted credentials, then redirect either to the 2fa form, or straight to the authorize page served at /oauth/authorize.
func (*Module) TokenPOSTHandler ¶
TokenPOSTHandler should be served as a POST at https://example.org/oauth/token The idea here is to serve an oauth access token to a user, which can be used for authorizing against non-public APIs.
func (*Module) TokenRevokePOSTHandler ¶
TokenRevokePOSTHandler swagger:operation POST /oauth/revoke oauthTokenRevoke
Revoke an access token to make it no longer valid for use.
---
tags:
- oauth
consumes:
- multipart/form-data
produces:
- application/json
parameters:
-
name: client_id
in: formData
description: The client ID, obtained during app registration.
type: string
required: true
-
name: client_secret
in: formData
description: The client secret, obtained during app registration.
type: string
required: true
-
name: token
in: formData
description: The previously obtained token, to be invalidated.
type: string
required: true
responses:
'200':
description: >-
OK - If you own the provided token, the API call will provide OK and an empty response `{}`.
This operation is idempotent, so calling this API multiple times will still return OK.
'400':
description: bad request
'403':
description: >-
forbidden - If you provide a token you do not own, the API call will return a 403 error.
'406':
description: not acceptable
'500':
description: internal server error
func (*Module) TwoFactorCodeGETHandler ¶
TwoFactorCodeGETHandler should be served at GET https://example.org/auth/2fa.
The 2fa template displays a simple form asking the user to input a code from their authenticator app.
func (*Module) TwoFactorCodePOSTHandler ¶
TwoFactorCodePOSTHandler should be served at POST https://example.org/auth/2fa.
The idea is to handle a submitted 2fa code, validate it, and if valid redirect to the /oauth/authorize page that the user would get to if they didn't have 2fa enabled.