Skip to Content
Signet

Organization SSO

Let each Organization sign in its members with its own OIDC provider.

Follow these steps to let an Organization use its own OIDC provider. All state lives behind an optional store; no User column is added.

1. Implement the connection store and domain verification

type ssoConnectionStore struct {
    mu          sync.Mutex
    byOrg       map[string]*signet.SSOConnection
    byDomain    map[string]*signet.SSOConnection
    byID        map[string]*signet.SSOConnection
}

func (s *ssoConnectionStore) Create(_ context.Context, c *signet.SSOConnection) error { /* persist */ }
func (s *ssoConnectionStore) ByOrganization(_ context.Context, orgID string) (*signet.SSOConnection, error) { /* lookup */ }
func (s *ssoConnectionStore) ByDomain(_ context.Context, domain string) (*signet.SSOConnection, error) { /* lookup */ }
func (s *ssoConnectionStore) ByID(_ context.Context, id string) (*signet.SSOConnection, error) { /* lookup */ }
func (s *ssoConnectionStore) List(context.Context) ([]*signet.SSOConnection, error) { /* all */ }
func (s *ssoConnectionStore) Delete(_ context.Context, id string) error { /* remove */ }

2. Configure SSO

cfg.SSO = &signet.SSOConfig{
    Connections: myConnectionStore,
    VerifyDomain: func(ctx context.Context, orgID, domain string) bool {
        return myDNS.Verified(ctx, orgID, domain)
    },
    DefaultRole: "member",
}
auth, err := signet.New(cfg)
if err != nil {
    panic(err)
}

A domain can only be bound after VerifyDomain returns true. The callback is the sole authority — fail closed.

3. Create an OIDC connection

connection, err := auth.CreateSSOConnection(ctx, signet.CreateSSOConnectionInput{
    OrganizationID: orgID,
    Protocol:       "oidc",
    Issuer:         "https://idp.acme.com",
    ClientID:       os.Getenv("SSO_CLIENT_ID"),
    ClientSecret:   os.Getenv("SSO_CLIENT_SECRET"),
    Domains:        []string{"acme.com"},
    SessionToken:   adminSessionToken,
})
if err != nil {
    return err
}

Connection management is limited to the organization's manager roles — the OrganizationRoles vocabulary, by default the owner and admin members — and requires a fresh Session.

4. Start and complete sign-in

start, err := auth.StartSSOSignIn(ctx, signet.SSOStartInput{
    Email: "alice@acme.com", // or OrganizationID
})
// Redirect the browser to start.URL, retaining start.State.

result, err := auth.CompleteSSOSignIn(ctx, signet.SSOCallbackInput{
    State: stateFromBrowser, Code: codeFromBrowser,
})
if err != nil {
    return err
}
// result.SessionToken is a normal Session.

The callback verifies the ID token with discovery, JWKS, issuer, audience, nonce and PKCE checks. A verified email just-in-time creates a User and a namespaced Account keyed by the IdP Subject, adds the User to the Organization with DefaultRole, sets the active-organization cookie and records sso as the Last sign-in method.

5. Use the HTTP endpoints

MethodPathAuthDescription
POST/sso/startnoneStart sign-in by Organization ID or email
GET/sso/callbacknoneVerify the assertion and create a Session
POST/sso/connectionsSessionCreate a verified connection
GET/sso/connectionsSessionList connections
DELETE/sso/connectionsSessionDelete a connection

An unknown organization, unbound domain and unverified domain all return the same generic failure, so sign-in cannot enumerate connections.

For XML-based providers, see SAML SSO.

The store interface is SSOConnectionStore; deleting a connection uses DeleteSSOConnectionInput.

On this page