sso

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidState       = errors.New("invalid or expired SSO state")
	ErrInvalidIDToken     = errors.New("invalid ID token")
	ErrProviderDisabled   = errors.New("SSO provider is not enabled")
	ErrInvalidLogoutToken = errors.New("invalid logout token")
)
View Source
var ErrWebhookMalformed = errors.New("malformed webhook payload")

ErrWebhookMalformed is a signed body that is not a usable event.

View Source
var ErrWebhookUnauthorized = errors.New("webhook signature or timestamp rejected")

ErrWebhookUnauthorized is a missing secret, bad signature or out-of-window timestamp.

Functions

This section is empty.

Types

type IdentityClaims

type IdentityClaims struct {
	Subject           string `json:"sub"`
	Email             string `json:"email"`
	Name              string `json:"name"`
	PreferredUsername string `json:"preferred_username"`
	Role              string `json:"role,omitempty"`
	Provider          string `json:"provider"` // "kysignon", "oidc", "saml"
	// SessionID is the provider's ID token `sid`; back-channel logout names the login by it.
	SessionID string `json:"sid,omitempty"`
	// IssuedAt is the ID token's iat: when the provider vouched for this login.
	IssuedAt time.Time `json:"-"`
	// AuthTime is the ID token's auth_time, when the user last authenticated at the provider; zero if absent.
	AuthTime time.Time `json:"-"`
}

IdentityClaims holds the unified identity extracted from any SSO provider.

type KySignOnClient

type KySignOnClient struct {
	// contains filtered or unexported fields
}

KySignOnClient manages interactions with the central KySignOn identity provider.

func NewKySignOnClient

func NewKySignOnClient(cfg config.SSOConfig, st store.Store) *KySignOnClient

func (*KySignOnClient) BuildAuthURL

func (k *KySignOnClient) BuildAuthURL(ctx context.Context, redirectURI, state, verifier, nonce string, stepUp bool) (string, error)

BuildAuthURL generates the authorization code URL with PKCE for KySignOn. A step-up sends max_age=0 so KyIdentity makes the user sign in again rather than reuse its session.

func (*KySignOnClient) ExchangeCode

func (k *KySignOnClient) ExchangeCode(ctx context.Context, code, verifier, redirectURI, expectedNonce string) (*IdentityClaims, error)

ExchangeCode exchanges the authorization code and verifier for identity claims.

func (*KySignOnClient) HandleSyncWebhook

func (k *KySignOnClient) HandleSyncWebhook(ctx context.Context, body []byte, signature string) error

HandleSyncWebhook processes inbound HMAC-SHA256 signed user updates from KySignOn server. Events apply only when newer than the account's last applied event; a replay or an out-of-order older event is acknowledged without effect.

func (*KySignOnClient) VerifyLogoutToken added in v0.5.0

func (k *KySignOnClient) VerifyLogoutToken(ctx context.Context, raw string) (*LogoutClaims, error)

VerifyLogoutToken verifies a back-channel logout token signed by KySignOn for this client.

type KySignOnSyncPayload

type KySignOnSyncPayload struct {
	Event       string `json:"event"` // "user.created", "user.updated", "user.deactivated", "user.deleted"
	ID          string `json:"id"`
	Username    string `json:"username"`
	Email       string `json:"email"`
	DisplayName string `json:"display_name"`
	Status      string `json:"status"`
	Timestamp   int64  `json:"timestamp"`
}

KySignOnSyncPayload defines the schema received during automatic directory replication webhooks. A role field, if sent, is ignored: application administration is an operator grant.

type LogoutClaims added in v0.5.0

type LogoutClaims struct {
	Subject   string
	SessionID string
	IssuedAt  time.Time
}

LogoutClaims names the login an OpenID Connect Back-Channel Logout token ended. SessionID is empty when the provider ended every login of Subject issued by IssuedAt.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL