Documentation
¶
Overview ¶
Package sso implements single sign-on over OpenID Connect (add-on spec 3.2, 5.11) and social sign-in with Google, Microsoft and GitHub (3.1): provider setup, claim and group mappings, just-in-time accounts, domain enforcement with break-glass Owners, a dry-run test sign-in and the browser flows (state, nonce and PKCE). Sessions are created by the accounts package exactly like a password sign-in.
Index ¶
- Variables
- func RedirectPath(slug string) string
- func Register(h huma.API, s *Service)
- func SocialConfigs(st store.InstanceSetting) map[string]SocialConfig
- func SocialRedirectPath(kind string) string
- type Redirect
- type SSOBreakGlassOwner
- type SSOClaimMap
- type SSOClaimSample
- type SSOCreateInput
- type SSODiscoveryInput
- type SSODiscoveryResult
- type SSOEnforcementInput
- type SSOEnforcementMember
- type SSOEnforcementPreview
- type SSOGroupMapping
- type SSOJIT
- type SSOJITInput
- type SSOListChoice
- type SSOPreset
- type SSOProviderDetail
- type SSOProviderInput
- type SSOProviderItem
- type SSOProviderList
- type SSOProviderPath
- type SSORejection
- type SSORoleChoice
- type SSOSecretInfo
- type SSOSocialInput
- type SSOSocialList
- type SSOSocialProvider
- type SSOStartQuery
- type SSOTestInput
- type SSOTestOutcome
- type SSOTestStart
- type SSOTestView
- type SSOWorkspaceChoice
- type Service
- func (s *Service) CallbackSSO(ctx context.Context, slug string, query url.Values, cookies []*http.Cookie) Redirect
- func (s *Service) CallbackSocial(ctx context.Context, kind string, query url.Values, cookies []*http.Cookie) Redirect
- func (s *Service) Create(ctx context.Context, in SSOCreateInput) (SSOProviderDetail, error)
- func (s *Service) Delete(ctx context.Context, id uuid.UUID) error
- func (s *Service) Disable(ctx context.Context, id uuid.UUID) (SSOProviderDetail, error)
- func (s *Service) Enable(ctx context.Context, id uuid.UUID) (SSOProviderDetail, error)
- func (s *Service) EnforcementPreview(ctx context.Context, id uuid.UUID, domains []string) (SSOEnforcementPreview, error)
- func (s *Service) Get(ctx context.Context, id uuid.UUID) (SSOProviderDetail, error)
- func (s *Service) List(ctx context.Context) (SSOProviderList, error)
- func (s *Service) MailApp(ctx context.Context, kind string) (clientID, secret, tenant string, ok bool, err error)
- func (s *Service) Routes(r chi.Router)
- func (s *Service) SaveSocial(ctx context.Context, kind string, in SSOSocialInput) ([]SSOSocialProvider, error)
- func (s *Service) SetEnforcement(ctx context.Context, id uuid.UUID, in SSOEnforcementInput) (SSOProviderDetail, error)
- func (s *Service) SocialProviders(ctx context.Context) ([]SSOSocialProvider, error)
- func (s *Service) SocialReady(ctx context.Context, st store.InstanceSetting, kind string) string
- func (s *Service) StartSSO(ctx context.Context, id uuid.UUID, req StartRequest) Redirect
- func (s *Service) StartSocial(ctx context.Context, kind string, req StartRequest) Redirect
- func (s *Service) StartTest(ctx context.Context, id uuid.UUID, in SSOTestInput) (SSOTestStart, *http.Cookie, error)
- func (s *Service) TestDiscovery(ctx context.Context, id uuid.UUID, in SSODiscoveryInput) (SSOProviderDetail, error)
- func (s *Service) Update(ctx context.Context, id uuid.UUID, in SSOProviderInput) (SSOProviderDetail, error)
- type SocialConfig
- type SocialEndpoints
- type StartRequest
Constants ¶
This section is empty.
Variables ¶
var DefaultSocialEndpoints = SocialEndpoints{
GoogleIssuer: "https://accounts.google.com",
MicrosoftBase: "https://login.microsoftonline.com",
GitHubAuthURL: "https://github.com/login/oauth/authorize",
GitHubTokenURL: "https://github.com/login/oauth/access_token",
GitHubAPI: "https://api.github.com",
}
DefaultSocialEndpoints are the real providers.
var Presets = []SSOPreset{ {Key: "google", Name: "Google Workspace", Issuer: "https://accounts.google.com", ShortName: "Google", IssuerPattern: "https://accounts.google.com", Scopes: []string{"openid", "profile", "email"}, App: "Google Cloud OAuth client", GroupsClaim: false, TwoFA: "trusted", DiscoveryHint: "Google's issuer is always https://accounts.google.com.", GroupsHint: "Google doesn't send a groups claim over OIDC. Map people by email domain (JIT default role) or assign roles individually in Team.", TrustedTwoFA: "Trusted from Google (2-Step Verification enforced in Workspace)", DocsURL: "https://developers.google.com/identity/openid-connect/openid-connect", DocsLabel: "Google OIDC docs"}, {Key: "entra", Name: "Microsoft Entra ID", ShortName: "Entra ID", IssuerPattern: "https://login.microsoftonline.com/{tenant-id}/v2.0", Scopes: []string{"openid", "profile", "email"}, App: "Entra app registration", GroupsClaim: true, GroupIDs: true, TwoFA: "amr", DiscoveryHint: "Entra ID issuer URLs use the tenant ID (a GUID) or the verified domain, for example https://login.microsoftonline.com/7c1a2b3d-…/v2.0. Find it under Entra ID → Overview → Tenant ID.", GroupsHint: "Groups arrive as a token claim, not a scope: turn on the groups claim in the app registration's token configuration.", GroupsMissingHint: "In the Entra app registration open Token configuration → Add groups claim and include security groups in the ID token. If a user is in more than 200 groups, Entra sends an overage link instead; use app roles then.", TrustedTwoFA: "Trusted from Entra ID (MFA enforced by Conditional Access)", DocsURL: "https://learn.microsoft.com/entra/identity-platform/v2-protocols-oidc", DocsLabel: "Entra OIDC docs"}, {Key: "okta", Name: "Okta", ShortName: "Okta", IssuerPattern: "https://{your-org}.okta.com/oauth2/default", Scopes: []string{"openid", "profile", "email", "groups"}, App: "Okta app integration", GroupsClaim: true, TwoFA: "amr", DiscoveryHint: "Okta issuer URLs are your Okta domain, or an authorization server such as https://acme.okta.com/oauth2/default. Find it under Security → API → Authorization Servers.", GroupsHint: "Add a groups claim to the authorization server (filter: matches regex .*) and request the groups scope.", GroupsMissingHint: "In Okta open Security → API → your authorization server → Claims and add a groups claim to the ID token, then request the groups scope.", TrustedTwoFA: "Trusted from Okta (MFA enforced by a sign-on policy)", DocsURL: "https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/", DocsLabel: "Okta OIDC docs"}, {Key: "keycloak", Name: "Keycloak", ShortName: "Keycloak", IssuerPattern: "https://{host}/realms/{realm}", Scopes: []string{"openid", "profile", "email"}, App: "Keycloak client", GroupsClaim: true, TwoFA: "amr", DiscoveryHint: "Keycloak issuer URLs end with the realm, for example https://sso.acme.io/realms/acme.", GroupsHint: "Add a Group Membership mapper to the client (token claim name groups, full group path off).", GroupsMissingHint: "In Keycloak open Clients → your client → Client scopes → dedicated scope and add a Group Membership mapper with the claim name groups.", TrustedTwoFA: "Trusted from Keycloak (OTP required by the realm's browser flow)", DocsURL: "https://www.keycloak.org/docs/latest/server_admin/#_oidc", DocsLabel: "Keycloak OIDC docs"}, {Key: "authentik", Name: "Authentik", ShortName: "Authentik", IssuerPattern: "https://{host}/application/o/{app-slug}/", Scopes: []string{"openid", "profile", "email"}, App: "Authentik provider", GroupsClaim: true, TwoFA: "amr", DiscoveryHint: "Authentik issuer URLs end with the application slug and a slash, for example https://auth.acme.io/application/o/reputecast/.", GroupsHint: "Authentik sends the user's groups in the groups claim of the profile scope.", GroupsMissingHint: "In Authentik check that the provider's scope mappings include the default profile mapping, which sends groups.", TrustedTwoFA: "Trusted from Authentik (MFA stage in the authentication flow)", DocsURL: "https://docs.goauthentik.io/docs/add-secure-apps/providers/oauth2/", DocsLabel: "Authentik OIDC docs"}, {Key: "oidc", Name: "Generic OIDC", ShortName: "the IdP", IssuerPattern: "https://idp.example.com", Scopes: []string{"openid", "profile", "email"}, App: "identity provider's client settings", GroupsClaim: true, TwoFA: "amr", DiscoveryHint: "The issuer is the URL before /.well-known/openid-configuration.", GroupsHint: "Configure your IdP to send the user's groups as a claim in the ID token.", GroupsMissingHint: "Configure your IdP to add the user's groups to the ID token, then run the test again.", TrustedTwoFA: "Trusted from the identity provider", DocsURL: "https://openid.net/specs/openid-connect-discovery-1_0.html", DocsLabel: "OIDC discovery spec"}, }
Presets in the order of the setup screen.
var SocialKinds = []string{"google", "microsoft", "github"}
SocialKinds in display order.
Functions ¶
func RedirectPath ¶
RedirectPath is where the IdP sends the browser back for a provider.
func SocialConfigs ¶
func SocialConfigs(st store.InstanceSetting) map[string]SocialConfig
SocialConfigs reads the social providers of the instance settings.
func SocialRedirectPath ¶
SocialRedirectPath is the callback of a social provider.
Types ¶
type SSOBreakGlassOwner ¶
type SSOBreakGlassOwner struct {
Name string `json:"name"`
Email string `json:"email"`
Workspace string `json:"workspace"`
// Methods they keep: "password + two-factor", "passkey".
Keeps string `json:"keeps"`
}
SSOBreakGlassOwner is an Owner who keeps their own sign-in while the domain is enforced.
type SSOClaimMap ¶
type SSOClaimMap struct {
Email string `json:"email" maxLength:"64"`
EmailVerified string `json:"emailVerified" maxLength:"64"`
Name string `json:"name" maxLength:"64"`
Groups string `json:"groups" maxLength:"64"`
}
SSOClaimMap names the claims that fill the account.
type SSOClaimSample ¶
type SSOClaimSample struct {
Field string `json:"field" enum:"email,email_verified,name,groups"`
Claim string `json:"claim"`
Found bool `json:"found"`
// Value is the sample as shown ("marcus@acme.io", ["3f2a…c91", …]).
Value string `json:"value,omitempty"`
Count int `json:"count,omitempty"`
// Missing replaces the sample when the claim wasn't sent ("not sent by Entra ID").
Missing string `json:"missing,omitempty"`
// Note explains what a missing claim means ("treated as verified for allowed domains").
Note string `json:"note,omitempty"`
}
SSOClaimSample is one row of the claim mapping table: what the last test sign-in returned for a field.
type SSOCreateInput ¶
type SSOCreateInput struct {
Preset string `json:"preset" enum:"google,entra,okta,keycloak,authentik,oidc"`
}
SSOCreateInput starts a provider from a preset.
type SSODiscoveryInput ¶
type SSODiscoveryInput struct {
IssuerURL string `json:"issuerUrl,omitempty" maxLength:"300"`
}
SSODiscoveryInput tests discovery, optionally for an issuer not saved yet.
type SSODiscoveryResult ¶
type SSODiscoveryResult struct {
OK bool `json:"ok"`
CheckedAt time.Time `json:"checkedAt"`
URL string `json:"url,omitempty"`
Status int `json:"status,omitempty"`
Millis int64 `json:"ms,omitempty"`
Error string `json:"error,omitempty"`
// Endpoints found: authorization, token, userinfo, JWKS.
Endpoints []string `json:"endpoints"`
Keys int `json:"keys"`
}
SSODiscoveryResult is the last discovery test.
type SSOEnforcementInput ¶
type SSOEnforcementInput struct {
// Domains to enforce; empty turns enforcement off.
Domains []string `json:"domains" maxItems:"20"`
// Confirm acknowledges who keeps password access (the dialog's list);
// required when turning enforcement on.
Confirm bool `json:"confirm,omitempty"`
}
SSOEnforcementInput turns domain enforcement on or off.
type SSOEnforcementMember ¶
type SSOEnforcementMember struct {
ID string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
AvatarColor string `json:"avatarColor"`
// Today and After describe how they sign in now and once enforced.
Today string `json:"today"`
After string `json:"after"`
BreakGlass bool `json:"breakGlass"`
// Unlinked: they don't sign in with the provider yet.
Unlinked bool `json:"unlinked"`
}
SSOEnforcementMember is one person at the enforced domain.
type SSOEnforcementPreview ¶
type SSOEnforcementPreview struct {
Provider string `json:"provider"`
Domains []string `json:"domains"`
Members []SSOEnforcementMember `json:"members"`
BreakGlass []SSOBreakGlassOwner `json:"breakGlass"`
// Conflict names another enabled provider that already enforces a domain.
Conflict string `json:"conflict,omitempty"`
Enforced bool `json:"enforced"`
}
SSOEnforcementPreview is what turning enforcement on would change.
type SSOGroupMapping ¶
type SSOGroupMapping struct {
Group string `json:"group" minLength:"1" maxLength:"200"`
Label string `json:"label,omitempty" maxLength:"80"`
WorkspaceID string `json:"workspaceId" format:"uuid"`
RoleKey string `json:"roleKey" maxLength:"64"`
// Lists restrict the role to some lists; empty means all lists.
Lists []string `json:"lists,omitempty" maxItems:"50"`
}
SSOGroupMapping is one group → workspace → role mapping.
type SSOJIT ¶
type SSOJIT struct {
Enabled bool `json:"enabled"`
WorkspaceID string `json:"workspaceId,omitempty"`
WorkspaceName string `json:"workspaceName,omitempty"`
RoleKey string `json:"roleKey,omitempty"`
RoleName string `json:"roleName,omitempty"`
}
SSOJIT is a provider's just-in-time account setting.
type SSOJITInput ¶
type SSOJITInput struct {
Enabled bool `json:"enabled"`
WorkspaceID string `json:"workspaceId,omitempty" maxLength:"36"`
RoleKey string `json:"roleKey,omitempty" maxLength:"64"`
}
SSOJITInput sets just-in-time accounts.
type SSOListChoice ¶
SSOListChoice is a list a mapping can be scoped to.
type SSOPreset ¶
type SSOPreset struct {
Key string `json:"key" enum:"google,entra,okta,keycloak,authentik,oidc"`
Name string `json:"name" example:"Microsoft Entra ID"`
// ShortName is used in sentences: "not sent by Entra ID".
ShortName string `json:"shortName" example:"Entra ID"`
// Issuer is fixed for Google; IssuerPattern shows the shape for the others.
Issuer string `json:"issuer,omitempty"`
IssuerPattern string `json:"issuerPattern"`
Scopes []string `json:"scopes"`
// App names where the redirect URI goes ("the Entra app registration").
App string `json:"app"`
// GroupsClaim is false when the IdP sends no groups over OIDC (Google).
GroupsClaim bool `json:"groupsClaim"`
// GroupIDs: groups arrive as object IDs that need readable labels (Entra).
GroupIDs bool `json:"groupIds"`
// TwoFA is the default two-factor mode: amr or trusted.
TwoFA string `json:"twoFactor" enum:"amr,trusted"`
// Hints for the setup screen.
DiscoveryHint string `json:"discoveryHint"`
GroupsHint string `json:"groupsHint"`
GroupsMissingHint string `json:"groupsMissingHint"`
TrustedTwoFA string `json:"trustedTwoFactor,omitempty" doc:"How the IdP enforces two-factor when it is trusted"`
DocsURL string `json:"docsUrl"`
DocsLabel string `json:"docsLabel"`
}
SSOPreset describes an identity provider family: the issuer pattern, scopes, claim names and the hints the setup screen shows. Presets holds them in English; In writes one in a reader's language (messages preset.*).
type SSOProviderDetail ¶
type SSOProviderDetail struct {
SSOProviderItem
PresetInfo SSOPreset `json:"presetInfo"`
RedirectURI string `json:"redirectUri"`
ClientID string `json:"clientId"`
Secret SSOSecretInfo `json:"secret"`
Scopes []string `json:"scopes"`
Claims SSOClaimMap `json:"claims"`
TwoFactorMode string `json:"twoFactorMode" enum:"amr,trusted"`
Discovery *SSODiscoveryResult `json:"discovery,omitempty"`
GroupMappings []SSOGroupMapping `json:"groupMappings"`
Test *SSOTestView `json:"test,omitempty"`
Workspaces []SSOWorkspaceChoice `json:"workspaces"`
BreakGlassList []SSOBreakGlassOwner `json:"breakGlassOwners"`
// EnableBlockers say what's missing before the provider can be enabled.
EnableBlockers []string `json:"enableBlockers"`
// Rejections are the latest sign-ins this provider turned away.
Rejections []SSORejection `json:"rejections"`
}
SSOProviderDetail is GET /admin/sso/{id}: everything the setup page shows.
type SSOProviderInput ¶
type SSOProviderInput struct {
// Preset switches a draft to another IdP family (enabled providers keep theirs).
Preset string `json:"preset,omitempty" enum:"google,entra,okta,keycloak,authentik,oidc"`
Name string `json:"name" minLength:"1" maxLength:"80"`
IssuerURL string `json:"issuerUrl" maxLength:"300"`
ClientID string `json:"clientId" maxLength:"300"`
// ClientSecret replaces the saved secret; it is never returned.
ClientSecret string `json:"clientSecret,omitempty" maxLength:"4000"`
// SecretExpiresOn is when the new secret expires at the IdP (YYYY-MM-DD).
SecretExpiresOn string `json:"secretExpiresOn,omitempty" maxLength:"10"`
Scopes []string `json:"scopes" maxItems:"20"`
Claims SSOClaimMap `json:"claims"`
AllowedDomains []string `json:"allowedDomains" maxItems:"50"`
JIT SSOJITInput `json:"jit"`
GroupMappings []SSOGroupMapping `json:"groupMappings" maxItems:"200"`
TwoFactorMode string `json:"twoFactorMode" enum:"amr,trusted"`
}
SSOProviderInput is PUT /admin/sso/{id}. The client secret is write-only: omit it to keep the saved one.
type SSOProviderItem ¶
type SSOProviderItem struct {
ID string `json:"id"`
Slug string `json:"slug"`
Preset string `json:"preset" enum:"google,entra,okta,keycloak,authentik,oidc"`
Name string `json:"name"`
Status string `json:"status" enum:"draft,enabled,disabled,error"`
Issuer string `json:"issuer"`
// Domains are the allowed email domains.
Domains []string `json:"domains"`
JIT SSOJIT `json:"jit"`
// GroupsClaim is false for presets without a groups claim (Google).
GroupsClaim bool `json:"groupsClaim"`
Mappings int `json:"mappings"`
Enforced []string `json:"enforced"`
// TwoFactor says how the IdP satisfies two-factor.
TwoFactor string `json:"twoFactor"`
EnabledAt *time.Time `json:"enabledAt,omitempty"`
// DiscoveryOK is nil before the first discovery test.
DiscoveryOK *bool `json:"discoveryOk,omitempty"`
// BreakGlass names the Owners who keep password access while enforced.
BreakGlass []string `json:"breakGlass"`
// Members is how many people sign in with this provider.
Members int `json:"members"`
}
SSOProviderItem is one provider in the lists (SSO providers tab, Authentication › SSO providers).
type SSOProviderList ¶
type SSOProviderList struct {
Items []SSOProviderItem `json:"items"`
Presets []SSOPreset `json:"presets"`
}
SSOProviderList is GET /admin/sso.
type SSOProviderPath ¶
type SSOProviderPath struct {
ProviderID string `path:"providerId" format:"uuid"`
}
SSOProviderPath is the {providerId} path parameter.
type SSORejection ¶
type SSORejection struct {
At time.Time `json:"at"`
Email string `json:"email"`
Reason string `json:"reason"`
Reference string `json:"reference,omitempty"`
}
SSORejection is a recent rejected sign-in.
type SSORoleChoice ¶
type SSORoleChoice struct {
Key string `json:"key"`
Name string `json:"name"`
// Grantable is false when you don't hold all of the role's permissions
// in that workspace (escalation guard), or for Owner.
Grantable bool `json:"grantable"`
Reason string `json:"reason,omitempty"`
}
SSORoleChoice is a role a mapping can grant.
type SSOSecretInfo ¶
type SSOSecretInfo struct {
Set bool `json:"set"`
SetAt *time.Time `json:"setAt,omitempty"`
SetBy string `json:"setBy,omitempty"`
ExpiresOn *time.Time `json:"expiresOn,omitempty" doc:"When the secret expires at the IdP, as entered by the admin"`
}
SSOSecretInfo describes the write-only client secret without revealing it.
type SSOSocialInput ¶
type SSOSocialInput struct {
Enabled bool `json:"enabled"`
ClientID string `json:"clientId" maxLength:"300"`
ClientSecret string `json:"clientSecret,omitempty" maxLength:"2000"`
Org string `json:"org,omitempty" maxLength:"100"`
Tenant string `json:"tenant,omitempty" maxLength:"100"`
}
SSOSocialInput configures a social provider. The secret is write-only.
type SSOSocialList ¶
type SSOSocialList struct {
Items []SSOSocialProvider `json:"items"`
}
SSOSocialList is GET /admin/social.
type SSOSocialProvider ¶
type SSOSocialProvider struct {
Kind string `json:"kind" enum:"google,microsoft,github"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Configured bool `json:"configured"`
ClientID string `json:"clientId"`
SecretSet bool `json:"secretSet"`
SecretSetAt *time.Time `json:"secretSetAt,omitempty"`
Org string `json:"org,omitempty"`
Tenant string `json:"tenant,omitempty"`
RedirectURI string `json:"redirectUri"`
// Linked is how many people have linked this provider.
Linked int `json:"linked"`
}
SSOSocialProvider is a social sign-in provider as the admin sees it.
type SSOStartQuery ¶
type SSOStartQuery struct {
LoginHint string `query:"login_hint" maxLength:"254" doc:"Email to pre-fill at the IdP"`
Next string `query:"next" maxLength:"1000" doc:"App path to open after signing in"`
Invite string `query:"invite" maxLength:"200" doc:"Invitation token: join its workspace with this identity"`
Intent string `query:"intent" enum:"signin,link" doc:"link adds the identity to the signed-in account"`
}
SSOStartQuery is the query of a start link.
type SSOTestInput ¶
type SSOTestInput struct {
Workspace string `json:"workspace" pattern:"^[a-z0-9][a-z0-9-]{1,62}$"`
}
SSOTestInput names the workspace the admin returns to after the test.
type SSOTestOutcome ¶
type SSOTestOutcome struct {
Tone string `json:"tone" enum:"ok,warn,bad,info,neutral"`
Label string `json:"label"`
Detail string `json:"detail"`
// Strong is a part of Detail shown in bold ("Admin → Editor").
Strong string `json:"strong,omitempty"`
// Code is a part of Detail shown in mono ("amr").
Code string `json:"code,omitempty"`
}
SSOTestOutcome is one row of "What this sign-in would do".
type SSOTestStart ¶
type SSOTestStart struct {
AuthorizeURL string `json:"authorizeUrl"`
}
SSOTestStart is where the test sign-in popup goes.
type SSOTestView ¶
type SSOTestView struct {
At time.Time `json:"at"`
By string `json:"by,omitempty"`
Error string `json:"error,omitempty"`
// Claims is the pretty-printed claims object.
Claims string `json:"claims,omitempty"`
Samples []SSOClaimSample `json:"samples"`
Outcome []SSOTestOutcome `json:"outcome"`
// GroupsMissing: mappings exist but the IdP sent no groups claim.
GroupsMissing bool `json:"groupsMissing"`
GroupsOverage bool `json:"groupsOverage"`
}
SSOTestView is the last test sign-in.
type SSOWorkspaceChoice ¶
type SSOWorkspaceChoice struct {
ID string `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
Roles []SSORoleChoice `json:"roles"`
Lists []SSOListChoice `json:"lists"`
}
SSOWorkspaceChoice is a workspace for the JIT default and the mappings.
type Service ¶
type Service struct {
Pool *pgxpool.Pool
Q *store.Queries
Audit *audit.Logger
Box *secrets.Box
Cfg *config.Config
Log *slog.Logger
Accounts *accounts.Service
// OnPolicyChange drops the cached authentication policy (App.InvalidatePolicy).
OnPolicyChange func()
// HTTP talks to identity providers. Nil uses a client with a 10 s timeout.
HTTP *http.Client
Now func() time.Time
// Endpoints of the social providers; tests point them at a fake server.
Social SocialEndpoints
}
Service holds the SSO domain's dependencies.
func (*Service) CallbackSSO ¶
func (s *Service) CallbackSSO(ctx context.Context, slug string, query url.Values, cookies []*http.Cookie) Redirect
CallbackSSO finishes an SSO flow: GET /auth/oidc/{slug}/callback.
func (*Service) CallbackSocial ¶
func (s *Service) CallbackSocial(ctx context.Context, kind string, query url.Values, cookies []*http.Cookie) Redirect
CallbackSocial finishes a social flow: GET /auth/social/{kind}/callback.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, in SSOCreateInput) (SSOProviderDetail, error)
Create adds a draft provider filled from its preset.
func (*Service) Delete ¶
Delete removes a provider that isn't live. The identities linked to it go with it; people keep their accounts.
func (*Service) EnforcementPreview ¶
func (s *Service) EnforcementPreview(ctx context.Context, id uuid.UUID, domains []string) (SSOEnforcementPreview, error)
EnforcementPreview lists who signs in how before and after enforcement.
func (*Service) List ¶
func (s *Service) List(ctx context.Context) (SSOProviderList, error)
List returns every SSO provider.
func (*Service) MailApp ¶
func (s *Service) MailApp(ctx context.Context, kind string) (clientID, secret, tenant string, ok bool, err error)
MailApp returns the client ID, secret and (Microsoft) tenant of the instance's Google or Microsoft sign-in app (Instance admin › Authentication) for placement tests' seed mailboxes, which connect with the same app. ok is false until both the ID and the secret are set; the app doesn't have to be turned on for signing in to ReputeCast.
func (*Service) Routes ¶
Routes adds the browser callbacks the identity providers redirect to. They sit outside /api because their URLs are registered at the IdP.
func (*Service) SaveSocial ¶
func (s *Service) SaveSocial(ctx context.Context, kind string, in SSOSocialInput) ([]SSOSocialProvider, error)
SaveSocial stores a social provider's settings and secret.
func (*Service) SetEnforcement ¶
func (s *Service) SetEnforcement(ctx context.Context, id uuid.UUID, in SSOEnforcementInput) (SSOProviderDetail, error)
SetEnforcement turns password, passkey and social sign-in off for the domains, except for break-glass Owners, who are marked so that their password sign-ins keep working (and are logged as break-glass).
func (*Service) SocialProviders ¶
func (s *Service) SocialProviders(ctx context.Context) ([]SSOSocialProvider, error)
SocialProviders lists the three social providers.
func (*Service) SocialReady ¶
SocialReady reports what's missing before a social provider can be on, in the request's language.
func (*Service) StartSSO ¶
StartSSO begins signing in with an SSO provider: the browser goes to the IdP with state, nonce and a PKCE challenge.
func (*Service) StartSocial ¶
StartSocial begins a social sign-in (or links one, or joins with an invitation).
func (*Service) StartTest ¶
func (s *Service) StartTest(ctx context.Context, id uuid.UUID, in SSOTestInput) (SSOTestStart, *http.Cookie, error)
StartTest begins a test sign-in: the admin signs in at the IdP in a popup; the callback stores the claims and signs nobody in.
func (*Service) TestDiscovery ¶
func (s *Service) TestDiscovery(ctx context.Context, id uuid.UUID, in SSODiscoveryInput) (SSOProviderDetail, error)
TestDiscovery fetches the issuer's discovery document and JWKS, stores the result (and the issuer when it was passed) and returns the provider.
func (*Service) Update ¶
func (s *Service) Update(ctx context.Context, id uuid.UUID, in SSOProviderInput) (SSOProviderDetail, error)
Update saves a provider (draft or live). Changed group mappings and the JIT default role go through the escalation guard.
type SocialConfig ¶
type SocialConfig struct {
Enabled bool `json:"enabled"`
ClientID string `json:"client_id,omitempty"`
// Org restricts GitHub sign-in to members of an organization.
Org string `json:"org,omitempty"`
// Tenant is Microsoft's: common (personal and work), organizations,
// consumers, or one tenant id or domain.
Tenant string `json:"tenant,omitempty"`
SecretSetAt *time.Time `json:"secret_set_at,omitempty"`
}
SocialConfig is one provider in instance_settings.social_providers. Client secrets live in social_secrets_enc, never here.
type SocialEndpoints ¶
type SocialEndpoints struct {
GoogleIssuer string
// MicrosoftBase is the Microsoft identity platform; issuers are
// {base}/{tenant}/v2.0, and the multi-tenant endpoints report a
// templated issuer ({base}/{tenantid}/v2.0).
MicrosoftBase string
GitHubAuthURL string
GitHubTokenURL string
GitHubAPI string
}
SocialEndpoints are the URLs of the social sign-in providers.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ssotest is a fake OpenID Connect issuer (and a fake GitHub) for tests and local screenshots: discovery, signing keys, an authorization endpoint that approves at once, a token endpoint that checks the client secret and the PKCE verifier and returns a signed ID token with the nonce, and userinfo.
|
Package ssotest is a fake OpenID Connect issuer (and a fake GitHub) for tests and local screenshots: discovery, signing keys, an authorization endpoint that approves at once, a token endpoint that checks the client secret and the PKCE verifier and returns a signed ID token with the nonce, and userinfo. |
|
fakeidp
command
Command fakeidp runs the test OpenID Connect issuer locally, so the SSO setup screens can be tried end to end without a real identity provider:
|
Command fakeidp runs the test OpenID Connect issuer locally, so the SSO setup screens can be tried end to end without a real identity provider: |