Documentation
¶
Overview ¶
Package hanko is the Hanko identity provider adapter. Hanko owns credentials and sessions: its <hanko-auth> element signs users in and stores the session token in the "hanko" cookie, and this adapter validates that token with Hanko on every request.
The Hanko tenant must allow account deletion (the adapter deletes users through Hanko's profile flow) and should require email verification. The "hanko" cookie must reach the app's host.
templ: version: v0.3.1070
Index ¶
- type Config
- type Hanko
- func (h *Hanko) Authenticate(r *http.Request) (identity.Identity, error)
- func (h *Hanko) Delete(ctx context.Context, r *http.Request) error
- func (h *Hanko) Logout(w http.ResponseWriter, r *http.Request) error
- func (h *Hanko) Mount(r gin.IRouter, layout ui.Layout)
- func (h *Hanko) MountProfile(r gin.IRouter, layout ui.Layout, logoutPath, emailChangedPath string, ...)
- func (h *Hanko) Name() string
- func (h *Hanko) ProfileCSP() web.CSP
- func (h *Hanko) ProfileSection(c *gin.Context) templ.Component
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// APIURL is the tenant's API URL, such as https://<tenant>.hanko.io. A self-hosted
// Hanko may have a base path.
APIURL string
// SignedInPath is where the login page sends users who arrive without a next
// path. Zero means "/".
SignedInPath string
}
Config configures the adapter.
type Hanko ¶
type Hanko struct {
// contains filtered or unexported fields
}
Hanko implements identity.Provider for Hanko.
func (*Hanko) Authenticate ¶
Authenticate validates the session cookie with Hanko. Validation always asks Hanko, so a signed-out or deleted user's token stops working immediately.
func (*Hanko) Delete ¶
Delete deletes the signed-in user through Hanko's profile flow. It returns nil only when Hanko reports the account_deleted state.
func (*Hanko) Logout ¶
Logout clears the session cookie, then ends the session at Hanko. The cookie is cleared even when Hanko cannot be reached; the error reports that case.
func (*Hanko) Mount ¶
Mount adds the sign-in page at "login" under r, rendered inside layout. A user who is already signed in continues to the next path.
func (*Hanko) MountProfile ¶
func (h *Hanko) MountProfile(r gin.IRouter, layout ui.Layout, logoutPath, emailChangedPath string, emailChanged func(c *gin.Context, email string) error)
MountProfile adds the profile UI's routes under r, the settings page's group, which must require sign-in. logoutPath is the sign-out route, emailChangedPath the page shown after an email change signs the user out, and emailChanged records a confirmed new address.
func (*Hanko) ProfileCSP ¶
ProfileCSP lists what pages that show the profile UI must allow.