Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
// Copyright © 2026 Ory Corp
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package template
|
|
|
|
import (
|
|
hydraclientgo "github.com/ory/hydra-client-go/v2"
|
|
)
|
|
|
|
type (
|
|
// OAuth2LoginRequest is a scoped view of the OAuth2 login request that
|
|
// initiated a self-service flow. It is embedded into courier template data
|
|
// so that messages can be branded per OAuth2 client without exposing the
|
|
// full flow object.
|
|
OAuth2LoginRequest struct {
|
|
Challenge string `json:"challenge"`
|
|
Client OAuth2Client `json:"client"`
|
|
}
|
|
|
|
// OAuth2Client contains the branding-relevant, admin-controlled fields of
|
|
// the OAuth2 client that initiated a self-service flow.
|
|
OAuth2Client struct {
|
|
ClientID string `json:"client_id"`
|
|
ClientName string `json:"client_name,omitempty"`
|
|
ClientURI string `json:"client_uri,omitempty"`
|
|
LogoURI string `json:"logo_uri,omitempty"`
|
|
Metadata any `json:"metadata,omitempty"`
|
|
}
|
|
)
|
|
|
|
// NewOAuth2LoginRequest maps the Hydra login request to the scoped view embedded
|
|
// into courier template data. Only branding-relevant, admin-controlled client
|
|
// fields are exposed to messaging channels.
|
|
func NewOAuth2LoginRequest(hlr *hydraclientgo.OAuth2LoginRequest) *OAuth2LoginRequest {
|
|
if hlr == nil {
|
|
return nil
|
|
}
|
|
return &OAuth2LoginRequest{
|
|
Challenge: hlr.Challenge,
|
|
Client: OAuth2Client{
|
|
ClientID: hlr.Client.GetClientId(),
|
|
ClientName: hlr.Client.GetClientName(),
|
|
ClientURI: hlr.Client.GetClientUri(),
|
|
LogoURI: hlr.Client.GetLogoUri(),
|
|
Metadata: hlr.Client.GetMetadata(),
|
|
},
|
|
}
|
|
}
|