Documentation ¶
Index ¶
- Constants
- type CreateIdentityResponse
- type CreateInviteLinkForIdentityRequest
- type CreateInviteLinkForIdentityResponse
- type HydraKratosClient
- func (c *HydraKratosClient) AcceptConsent(ctx context.Context, challenge string) (*RedirectResponse, error)
- func (c *HydraKratosClient) AcceptHydraLogin(ctx context.Context, challenge string, whoamiResp *Whoami) (*RedirectResponse, error)
- func (c *HydraKratosClient) CreateIdentity(ctx context.Context, email string) (*CreateIdentityResponse, error)
- func (c *HydraKratosClient) CreateInviteLinkForIdentity(ctx context.Context, req *CreateInviteLinkForIdentityRequest) (*CreateInviteLinkForIdentityResponse, error)
- func (c *HydraKratosClient) GetUserIDFromToken(ctx context.Context, token string) (string, error)
- func (c *HydraKratosClient) GetUserInfo(ctx context.Context, userID string) (*KratosUserInfo, error)
- func (c *HydraKratosClient) HandleLogin(session *sessions.Session, w http.ResponseWriter, r *http.Request) error
- func (c *HydraKratosClient) InterceptHydraUserConsent(hydraConsentURL string, ogHeader http.Header) (http.Header, string, error)
- func (c *HydraKratosClient) RedirectToLogin(session *sessions.Session, w http.ResponseWriter, r *http.Request) error
- func (c *HydraKratosClient) SessionKey() string
- func (c *HydraKratosClient) Whoami(ctx context.Context, r *http.Request) (*Whoami, error)
- type HydraKratosConfig
- type KratosUserInfo
- type RedirectResponse
- type Whoami
Constants ¶
const HydraLoginStateKey string = "hydra_login_state"
HydraLoginStateKey is the hydra login state key.
const IDProviderSessionKey string = "ossidprovider"
IDProviderSessionKey is the key for the cookie session storing idp data.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateIdentityResponse ¶
CreateIdentityResponse contains relevant information about the Identity that was created.
type CreateInviteLinkForIdentityRequest ¶
type CreateInviteLinkForIdentityRequest struct {
AuthProviderID string
}
CreateInviteLinkForIdentityRequest is the request value for the invite link method.
type CreateInviteLinkForIdentityResponse ¶
type CreateInviteLinkForIdentityResponse struct {
InviteLink string
}
CreateInviteLinkForIdentityResponse contains the response for the invite link method.
type HydraKratosClient ¶
type HydraKratosClient struct { Config *HydraKratosConfig // contains filtered or unexported fields }
HydraKratosClient implements the Client interface for the a Hydra and Kratos integration.
func NewHydraKratosClient ¶
func NewHydraKratosClient() (*HydraKratosClient, error)
NewHydraKratosClient creates a new client with the default config.
func NewHydraKratosClientFromConfig ¶
func NewHydraKratosClientFromConfig(cfg *HydraKratosConfig) (*HydraKratosClient, error)
NewHydraKratosClientFromConfig creates a new client from a config.
func (*HydraKratosClient) AcceptConsent ¶
func (c *HydraKratosClient) AcceptConsent(ctx context.Context, challenge string) (*RedirectResponse, error)
AcceptConsent acepts the consent request for the particular challenge.
func (*HydraKratosClient) AcceptHydraLogin ¶
func (c *HydraKratosClient) AcceptHydraLogin(ctx context.Context, challenge string, whoamiResp *Whoami) (*RedirectResponse, error)
AcceptHydraLogin sends a request to accept the login on the hydra endpoint.
func (*HydraKratosClient) CreateIdentity ¶
func (c *HydraKratosClient) CreateIdentity(ctx context.Context, email string) (*CreateIdentityResponse, error)
CreateIdentity creates an identity for the comparable email.
func (*HydraKratosClient) CreateInviteLinkForIdentity ¶
func (c *HydraKratosClient) CreateInviteLinkForIdentity(ctx context.Context, req *CreateInviteLinkForIdentityRequest) (*CreateInviteLinkForIdentityResponse, error)
CreateInviteLinkForIdentity creates a Kratos recovery link for the identity, which can act like a one-time use invitelink.
func (*HydraKratosClient) GetUserIDFromToken ¶
GetUserIDFromToken returns the userID from the subject portion of the access token.
func (*HydraKratosClient) GetUserInfo ¶
func (c *HydraKratosClient) GetUserInfo(ctx context.Context, userID string) (*KratosUserInfo, error)
GetUserInfo returns the UserInfo for the userID.
func (*HydraKratosClient) HandleLogin ¶
func (c *HydraKratosClient) HandleLogin(session *sessions.Session, w http.ResponseWriter, r *http.Request) error
HandleLogin handles the login for Hydra and Kratos.
func (*HydraKratosClient) InterceptHydraUserConsent ¶
func (c *HydraKratosClient) InterceptHydraUserConsent(hydraConsentURL string, ogHeader http.Header) (http.Header, string, error)
InterceptHydraUserConsent performs the user consent flow bypassing normal user interaction. Hydra uses consent to allow users to configure consent for third-party OAuth clients. Our auth system does not allow third-party OAuth clients and so we can skip the consent stage.
func (*HydraKratosClient) RedirectToLogin ¶
func (c *HydraKratosClient) RedirectToLogin(session *sessions.Session, w http.ResponseWriter, r *http.Request) error
RedirectToLogin sets up the login flow and redirects the response writer to the Kratos URL login.
func (*HydraKratosClient) SessionKey ¶
func (c *HydraKratosClient) SessionKey() string
SessionKey returns the string key under which cookie the session info should be stored.
type HydraKratosConfig ¶
type HydraKratosConfig struct { // Path to the Hydra Admin endpoint. HydraAdminHost string // Path to the Hydra Public endpoint. HydraPublicHost string // The browser-accessible URL for the Hydra instance. Used as part of the redirect authorization flows. HydraBrowserURL string // The browser-accessible URL for the Kratos instance. Used as part of the redirect login flows. KratosBrowserURL string // Path to the Kratos Public endpoint. KratosAdminHost string // Path to the Kratos Public endpoint. KratosPublicHost string // The path that Hydra redirects to when asking for consent. HydraConsentPath string // The OAuth client ID used to manage authorization with Hydra. HydraClientID string // Optional argument. If not set, will be created later on. HTTPClient *http.Client }
HydraKratosConfig is the configuration for the IDProvider using Kratos and Hydra.
type KratosUserInfo ¶
type KratosUserInfo struct { Email string `json:"email,omitempty"` // KratosID is the ID assigned to the user by Kratos. KratosID string `json:"-"` }
KratosUserInfo contains the user information format as stored in Kratos.
type RedirectResponse ¶
type RedirectResponse struct {
RedirectTo *string
}
RedirectResponse contains information about where a URL should redirect a user.