idprovider

package
v0.0.0-...-cd22e1a Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const HydraLoginStateKey string = "hydra_login_state"

HydraLoginStateKey is the hydra login state key.

View Source
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

type CreateIdentityResponse struct {
	IdentityProvider string
	AuthProviderID   string
}

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

CreateInviteLinkForIdentity creates a Kratos recovery link for the identity, which can act like a one-time use invitelink.

func (*HydraKratosClient) GetUserIDFromToken

func (c *HydraKratosClient) GetUserIDFromToken(ctx context.Context, token string) (string, error)

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.

func (*HydraKratosClient) Whoami

func (c *HydraKratosClient) Whoami(ctx context.Context, r *http.Request) (*Whoami, error)

Whoami implements the Kratos whoami flow.

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.

type Whoami

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

Whoami contains information about a user.

func (*Whoami) ID

func (w *Whoami) ID() string

ID returns the ID of the whoami.

Jump to

Keyboard shortcuts

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