Documentation
¶
Overview ¶
Package flows serves what Hydra hands over: the consent and logout steps of a browser's OAuth 2.0 flow (hook Consent, event LoggedOut) and the token hook (hook TokenClaims).
Index ¶
- Constants
- Variables
- type ConsentGranted
- type ConsentIn
- type ConsentOut
- type Flows
- func (f *Flows) BindingChanges(ctx context.Context) <-chan struct{}
- func (f *Flows) Bound(name string) bool
- func (f *Flows) Callbacks() http.Handler
- func (f *Flows) ConsentRef() hook.Ref[ConsentIn, ConsentOut]
- func (f *Flows) Granted() event.Ref[ConsentGranted]
- func (f *Flows) Hooks() []string
- func (f *Flows) LoggedOutRef() event.Ref[LoggedOut]
- func (f *Flows) Public() http.Handler
- func (f *Flows) Stats() []Stat
- func (f *Flows) TokenRef() hook.Ref[TokenIn, TokenOut]
- type LoggedOut
- type Stat
- type TokenIn
- type TokenOut
Constants ¶
const ( DecisionAccept = "accept" DecisionReject = "reject" DecisionUI = "ui" )
Decisions of a consent.
Variables ¶
var ErrNoChallenge = errors.New("the request carries no challenge from Hydra")
ErrNoChallenge: the browser came without Hydra's challenge.
Functions ¶
This section is empty.
Types ¶
type ConsentGranted ¶
type ConsentGranted struct {
Subject string `json:"subject"`
ClientID string `json:"client_id"`
Scope []string `json:"scope"`
// Automatic: granted without asking (trusted or remembered).
Automatic bool `json:"automatic"`
}
ConsentGranted is a consent given.
type ConsentIn ¶
type ConsentIn struct {
Subject string `json:"subject"`
ClientID string `json:"client_id"`
ClientName string `json:"client_name,omitempty"`
Metadata json.RawMessage `json:"client_metadata,omitempty"`
// SkipConsent: the client is trusted (first-party).
SkipConsent bool `json:"skip_consent"`
// Remembered: the subject consented to this client before.
Remembered bool `json:"remembered"`
RequestedScope []string `json:"requested_scope"`
RequestedAudience []string `json:"requested_audience,omitempty"`
ACR string `json:"acr,omitempty"`
AMR []string `json:"amr,omitempty"`
LoginContext json.RawMessage `json:"login_context,omitempty"`
OIDCContext json.RawMessage `json:"oidc_context,omitempty"`
}
ConsentIn is a consent Hydra asks for.
type ConsentOut ¶
type ConsentOut struct {
// Decision is accept, reject or ui; empty: backplane-hydra's default
// (accept a trusted or remembered client, else the consent UI, else
// reject).
Decision string `json:"decision,omitempty" validate:"omitempty,oneof=accept reject ui"`
// GrantScope defaults to the requested scope.
GrantScope []string `json:"grant_scope,omitempty"`
GrantAudience []string `json:"grant_audience,omitempty"`
IDTokenClaims json.RawMessage `json:"id_token_claims,omitempty"`
AccessTokenClaims json.RawMessage `json:"access_token_claims,omitempty"`
// Remember the consent; RememberFor seconds (zero: for ever).
Remember *bool `json:"remember,omitempty"`
RememberFor int64 `json:"remember_for,omitempty"`
// Error and ErrorDescription of a rejection.
Error string `json:"error,omitempty"`
ErrorDescription string `json:"error_description,omitempty"`
}
ConsentOut decides it and adds claims.
type Flows ¶
Flows declares the hooks and events and serves the browser endpoints and Hydra's token hook.
func New ¶
func New(parent deps.Scope, hydra ory.Client, key string, settings config.Live[overlay.Settings]) *Flows
New declares the hooks and events under parent.
func (*Flows) BindingChanges ¶
BindingChanges signals when the bound hooks change.
func (*Flows) ConsentRef ¶
func (f *Flows) ConsentRef() hook.Ref[ConsentIn, ConsentOut]
ConsentRef, TokenRef, Granted and LoggedOutRef are the declared refs.
func (*Flows) Granted ¶
func (f *Flows) Granted() event.Ref[ConsentGranted]
Granted is ConsentGranted.
func (*Flows) LoggedOutRef ¶
LoggedOutRef is LoggedOut.
type LoggedOut ¶
type LoggedOut struct {
Subject string `json:"subject"`
SID string `json:"sid,omitempty"`
ClientID string `json:"client_id,omitempty"`
}
LoggedOut is a logout through Hydra.
type Stat ¶
type Stat struct {
Point string
Calls uint64
Failures uint64
LastAt time.Time
LastOutcome string
LastError string
LastLatency time.Duration
}
Stat is how one point has been doing since start.
type TokenIn ¶
type TokenIn struct {
ClientID string `json:"client_id"`
Subject string `json:"subject,omitempty"`
GrantTypes []string `json:"grant_types"`
RequestedScopes []string `json:"requested_scopes,omitempty"`
GrantedScopes []string `json:"granted_scopes,omitempty"`
GrantedAudience []string `json:"granted_audience,omitempty"`
Payload map[string][]string `json:"payload,omitempty" schemapb:"secret=true"`
// Session is Hydra's session of the token: its current claims.
Session json.RawMessage `json:"session,omitempty"`
}
TokenIn is a token Hydra is about to issue.
type TokenOut ¶
type TokenOut struct {
AccessTokenClaims json.RawMessage `json:"access_token_claims,omitempty"`
IDTokenClaims json.RawMessage `json:"id_token_claims,omitempty"`
// Deny refuses the token (access_denied).
Deny bool `json:"deny,omitempty"`
}
TokenOut replaces the token's extra claims; empty: unchanged.