SAML SSO
Per-organization SAML 2.0 Web SSO with signed assertions.
SAML is a protocol variant of an SSO connection. Follow these steps to add it to an Organization.
1. Configure SSO
cfg.SSO = &signet.SSOConfig{
Connections: myConnectionStore,
VerifyDomain: func(ctx context.Context, orgID, domain string) bool {
return myDNS.Verified(ctx, orgID, domain)
},
}
auth, err := signet.New(cfg)
if err != nil {
panic(err)
}The connection store is the same one used for OIDC SSO. XML signature handling is isolated inside Signet behind a pinned protocol library.
2. Pin the IdP metadata
metadataXML := []byte(`<!-- IdP metadata XML with a signing certificate -->`)
connection, err := auth.CreateSSOConnection(ctx, signet.CreateSSOConnectionInput{
OrganizationID: orgID,
Protocol: "saml",
Issuer: "https://idp.acme.com",
Domains: []string{"acme.com"},
Metadata: string(metadataXML),
SessionToken: adminSessionToken,
})
if err != nil {
return err
}The SSO URL in the metadata must be HTTPS. Metadata is pinned — a certificate change requires an explicit connection update.
3. Start the ceremony
start, err := auth.StartSAMLSignIn(ctx, signet.SAMLStartInput{
OrganizationID: orgID, // or Email: "alice@acme.com"
})
if err != nil {
return err
}
// start.URL is the IdP destination.
// start.State is the single-use ceremony Token.
// start.RequestID identifies the signed AuthnRequest.4. Complete the assertion at the ACS endpoint
The IdP posts a SAML response to POST /saml/acs. Signet validates signature, issuer, audience, validity window, InResponseTo and replay before provisioning:
result, err := auth.CompleteSAMLSignIn(ctx, stateFromBrowser, request)
if err != nil {
return err
}
// result.SessionToken is a normal Session.
// result.OrganizationID is the selected Active organization.The handler sets the Session and active-organization cookies and records saml as the Last sign-in method. NameID becomes the external Subject; email and email_verified attributes are normalized before SSOConfig.MapClaims may override them. Missing or unverified email is rejected.
Verify
A signed assertion creates a User with a namespaced Account, adds the User to the Organization with the configured default role, and emits Audit events. Unsigned assertions, wrong InResponseTo, wrong audience and replayed assertions are rejected. SLO, artifact binding and IdP-initiated SSO are not included.