Documentation
¶
Index ¶
- Variables
- type IdentityClaims
- type KySignOnClient
- func (k *KySignOnClient) BuildAuthURL(ctx context.Context, redirectURI, state, verifier, nonce string, stepUp bool) (string, error)
- func (k *KySignOnClient) ExchangeCode(ctx context.Context, code, verifier, redirectURI, expectedNonce string) (*IdentityClaims, error)
- func (k *KySignOnClient) HandleSyncWebhook(ctx context.Context, body []byte, signature string) error
- func (k *KySignOnClient) VerifyLogoutToken(ctx context.Context, raw string) (*LogoutClaims, error)
- type KySignOnSyncPayload
- type LogoutClaims
Constants ¶
This section is empty.
Variables ¶
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") )
var ErrWebhookMalformed = errors.New("malformed webhook payload")
ErrWebhookMalformed is a signed body that is not a usable event.
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.