diff --git a/.schema/openapi/patches/selfservice.yaml b/.schema/openapi/patches/selfservice.yaml index 88aca38afef4..7887c1c2da74 100644 --- a/.schema/openapi/patches/selfservice.yaml +++ b/.schema/openapi/patches/selfservice.yaml @@ -52,7 +52,7 @@ - "$ref": "#/components/schemas/updateLoginFlowWithLookupSecretMethod" - "$ref": "#/components/schemas/updateLoginFlowWithCodeMethod" - "$ref": "#/components/schemas/updateLoginFlowWithPasskeyMethod" - - "$ref": "#/components/schemas/updateLoginFlowWithTwoStepMethod" + - "$ref": "#/components/schemas/updateLoginFlowWithIdentifierFirstMethod" - op: add path: /components/schemas/updateLoginFlowBody/discriminator value: @@ -65,7 +65,7 @@ lookup_secret: "#/components/schemas/updateLoginFlowWithLookupSecretMethod" code: "#/components/schemas/updateLoginFlowWithCodeMethod" passkey: "#/components/schemas/updateLoginFlowWithPasskeyMethod" - two_step: "#/components/schemas/updateLoginFlowWithIdentifierFirstMethod" + identifier_first: "#/components/schemas/updateLoginFlowWithIdentifierFirstMethod" - op: add path: /components/schemas/loginFlowState/enum value: diff --git a/Makefile b/Makefile index 7af282d469c3..0395085b9849 100644 --- a/Makefile +++ b/Makefile @@ -193,8 +193,8 @@ migrations-sync: .bin/ory ory dev pop migration sync persistence/sql/migrations/templates persistence/sql/migratest/testdata script/add-down-migrations.sh -.PHONY: test-update-snapshots -test-update-snapshots: +.PHONY: test-refresh +test-refresh: UPDATE_SNAPSHOTS=true go test -tags sqlite,json1,refresh -short ./... .PHONY: post-release diff --git a/cmd/cliclient/client.go b/cmd/cliclient/client.go index fc7a4bed451c..82a41f2aacb1 100644 --- a/cmd/cliclient/client.go +++ b/cmd/cliclient/client.go @@ -18,7 +18,7 @@ import ( "github.com/spf13/pflag" - kratos "github.com/ory/client-go" + kratos "github.com/ory/kratos/internal/httpclient" ) const ( diff --git a/cmd/clidoc/main.go b/cmd/clidoc/main.go index 6ed8df8d1748..a498aa9dfca6 100644 --- a/cmd/clidoc/main.go +++ b/cmd/clidoc/main.go @@ -177,6 +177,8 @@ func init() { "NewErrorValidationAddressUnknown": text.NewErrorValidationAddressUnknown(), "NewInfoSelfServiceLoginCodeMFA": text.NewInfoSelfServiceLoginCodeMFA(), "NewInfoSelfServiceLoginCodeMFAHint": text.NewInfoSelfServiceLoginCodeMFAHint("{maskedIdentifier}"), + "NewInfoLoginPassword": text.NewInfoLoginPassword(), + "NewErrorValidationAccountNotFound": text.NewErrorValidationAccountNotFound(), } } diff --git a/cmd/identities/definitions.go b/cmd/identities/definitions.go index 876eeba9f4a9..956266e70aa3 100644 --- a/cmd/identities/definitions.go +++ b/cmd/identities/definitions.go @@ -6,7 +6,7 @@ package identities import ( "strings" - kratos "github.com/ory/client-go" + kratos "github.com/ory/kratos/internal/httpclient" "github.com/ory/x/cmdx" ) diff --git a/cmd/identities/get.go b/cmd/identities/get.go index a575af2920e9..677ac3bc9121 100644 --- a/cmd/identities/get.go +++ b/cmd/identities/get.go @@ -6,7 +6,7 @@ package identities import ( "fmt" - kratos "github.com/ory/client-go" + kratos "github.com/ory/kratos/internal/httpclient" "github.com/ory/kratos/x" "github.com/ory/x/cmdx" "github.com/ory/x/stringsx" diff --git a/cmd/identities/import.go b/cmd/identities/import.go index 16641f919477..1de8a22de385 100644 --- a/cmd/identities/import.go +++ b/cmd/identities/import.go @@ -7,7 +7,7 @@ import ( "encoding/json" "fmt" - kratos "github.com/ory/client-go" + kratos "github.com/ory/kratos/internal/httpclient" "github.com/ory/x/cmdx" diff --git a/cmd/identities/import_test.go b/cmd/identities/import_test.go index 1e8031b906ac..8db159de9cff 100644 --- a/cmd/identities/import_test.go +++ b/cmd/identities/import_test.go @@ -19,8 +19,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tidwall/gjson" - kratos "github.com/ory/client-go" "github.com/ory/kratos/driver/config" + kratos "github.com/ory/kratos/internal/httpclient" ) func TestImportCmd(t *testing.T) { diff --git a/driver/config/config.go b/driver/config/config.go index d9615451777e..0c5b11ee0175 100644 --- a/driver/config/config.go +++ b/driver/config/config.go @@ -134,7 +134,7 @@ const ( ViperKeySelfServiceRegistrationAfter = "selfservice.flows.registration.after" ViperKeySelfServiceRegistrationBeforeHooks = "selfservice.flows.registration.before.hooks" ViperKeySelfServiceLoginUI = "selfservice.flows.login.ui_url" - ViperKeySelfServiceLoginFlowTwoStepEnabled = "selfservice.flows.login.two_step.enabled" + ViperKeySelfServiceLoginFlowStyle = "selfservice.flows.login.style" ViperKeySecurityAccountEnumerationMitigate = "security.account_enumeration.mitigate" ViperKeySelfServiceLoginRequestLifespan = "selfservice.flows.login.lifespan" ViperKeySelfServiceLoginAfter = "selfservice.flows.login.after" @@ -776,7 +776,7 @@ func (p *Config) SelfServiceStrategy(ctx context.Context, strategy string) *Self var err error config, err = json.Marshal(pp.GetF(basePath+".config", config)) if err != nil { - p.l.WithError(err).Warn("Unable to marshal self service strategy configuration.") + p.l.WithError(err).Warn("Unable to marshal self-service strategy configuration.") config = json.RawMessage("{}") } @@ -784,12 +784,10 @@ func (p *Config) SelfServiceStrategy(ctx context.Context, strategy string) *Self // we need to forcibly set these values here: defaultEnabled := false switch strategy { - case "identity_discovery": - defaultEnabled = p.SelfServiceLoginFlowTwoStepEnabled(ctx) - break + case "identifier_first": + defaultEnabled = p.SelfServiceLoginFlowIdentifierFirstEnabled(ctx) case "code", "password", "profile": defaultEnabled = true - break } // Backwards compatibility for the old "passwordless_enabled" key @@ -1619,8 +1617,13 @@ func (p *Config) PasswordMigrationHook(ctx context.Context) (hook *PasswordMigra return hook } -func (p *Config) SelfServiceLoginFlowTwoStepEnabled(ctx context.Context) bool { - return p.GetProvider(ctx).Bool(ViperKeySelfServiceLoginFlowTwoStepEnabled) +func (p *Config) SelfServiceLoginFlowIdentifierFirstEnabled(ctx context.Context) bool { + switch p.GetProvider(ctx).String(ViperKeySelfServiceLoginFlowStyle) { + case "identifier_first": + return true + default: + return false + } } func (p *Config) SecurityAccountEnumerationMitigate(ctx context.Context) bool { diff --git a/driver/registry_default.go b/driver/registry_default.go index 0c5f59238d28..c77ab5d783f2 100644 --- a/driver/registry_default.go +++ b/driver/registry_default.go @@ -6,13 +6,14 @@ package driver import ( "context" "crypto/sha256" - "github.com/ory/kratos/selfservice/strategy/multistep" "net/http" "strings" "sync" "testing" "time" + "github.com/ory/kratos/selfservice/strategy/idfirst" + "github.com/cenkalti/backoff" "github.com/dgraph-io/ristretto" "github.com/gobuffalo/pop/v6" @@ -325,7 +326,7 @@ func (m *RegistryDefault) selfServiceStrategies() []any { passkey.NewStrategy(m), webauthn.NewStrategy(m), lookup.NewStrategy(m), - multistep.NewStrategy(m), + idfirst.NewStrategy(m), } } } @@ -381,6 +382,7 @@ nextStrategy: continue nextStrategy } } + if m.strategyLoginEnabled(ctx, s.ID().String()) { loginStrategies = append(loginStrategies, s) } diff --git a/driver/registry_default_test.go b/driver/registry_default_test.go index fa3e7772c62a..a52b4fc6072c 100644 --- a/driver/registry_default_test.go +++ b/driver/registry_default_test.go @@ -872,7 +872,7 @@ func TestDefaultRegistry_AllStrategies(t *testing.T) { _, reg := internal.NewVeryFastRegistryWithoutDB(t) t.Run("case=all login strategies", func(t *testing.T) { - expects := []string{"password", "oidc", "code", "totp", "passkey", "webauthn", "lookup_secret"} + expects := []string{"password", "oidc", "code", "totp", "passkey", "webauthn", "lookup_secret", "identifier_first"} s := reg.AllLoginStrategies() require.Len(t, s, len(expects)) for k, e := range expects { diff --git a/examples/go/pkg/common.go b/examples/go/pkg/common.go index edb8c17e2e19..f39725103e33 100644 --- a/examples/go/pkg/common.go +++ b/examples/go/pkg/common.go @@ -11,11 +11,9 @@ import ( "os" "testing" - "github.com/ory/kratos/x" - - "github.com/ory/kratos/internal/testhelpers" - ory "github.com/ory/client-go" + "github.com/ory/kratos/internal/testhelpers" + "github.com/ory/kratos/x" ) func PrintJSONPretty(v interface{}) { diff --git a/examples/go/selfservice/recovery/main_test.go b/examples/go/selfservice/recovery/main_test.go index d37a561227eb..b4ca43c511d6 100644 --- a/examples/go/selfservice/recovery/main_test.go +++ b/examples/go/selfservice/recovery/main_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ory "github.com/ory/client-go" "github.com/ory/kratos/examples/go/pkg" + ory "github.com/ory/kratos/internal/httpclient" "github.com/ory/kratos/internal/testhelpers" ) diff --git a/examples/go/selfservice/settings/main_test.go b/examples/go/selfservice/settings/main_test.go index 12518930724a..1dd5fa8cf77c 100644 --- a/examples/go/selfservice/settings/main_test.go +++ b/examples/go/selfservice/settings/main_test.go @@ -6,7 +6,7 @@ package main import ( "testing" - ory "github.com/ory/client-go" + ory "github.com/ory/kratos/internal/httpclient" "github.com/stretchr/testify/assert" diff --git a/examples/go/selfservice/verification/main_test.go b/examples/go/selfservice/verification/main_test.go index 6a6621a15657..ca9ba687fb12 100644 --- a/examples/go/selfservice/verification/main_test.go +++ b/examples/go/selfservice/verification/main_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ory "github.com/ory/client-go" "github.com/ory/kratos/examples/go/pkg" + ory "github.com/ory/kratos/internal/httpclient" "github.com/ory/kratos/internal/testhelpers" ) diff --git a/identity/credentials.go b/identity/credentials.go index 3c7fa0f31834..3cc910c5a74e 100644 --- a/identity/credentials.go +++ b/identity/credentials.go @@ -88,8 +88,6 @@ const ( CredentialsTypeCodeAuth CredentialsType = "code" CredentialsTypePasskey CredentialsType = "passkey" CredentialsTypeProfile CredentialsType = "profile" - - TwoStep CredentialsType = "identity_discovery" // TODO move this somewhere else ) func (c CredentialsType) String() string { diff --git a/internal/client-go/.openapi-generator/FILES b/internal/client-go/.openapi-generator/FILES index 8f05b235508f..c573997505d8 100644 --- a/internal/client-go/.openapi-generator/FILES +++ b/internal/client-go/.openapi-generator/FILES @@ -100,6 +100,7 @@ docs/UiText.md docs/UpdateIdentityBody.md docs/UpdateLoginFlowBody.md docs/UpdateLoginFlowWithCodeMethod.md +docs/UpdateLoginFlowWithIdentifierFirstMethod.md docs/UpdateLoginFlowWithLookupSecretMethod.md docs/UpdateLoginFlowWithOidcMethod.md docs/UpdateLoginFlowWithPasskeyMethod.md @@ -221,6 +222,7 @@ model_ui_text.go model_update_identity_body.go model_update_login_flow_body.go model_update_login_flow_with_code_method.go +model_update_login_flow_with_identifier_first_method.go model_update_login_flow_with_lookup_secret_method.go model_update_login_flow_with_oidc_method.go model_update_login_flow_with_passkey_method.go diff --git a/internal/client-go/README.md b/internal/client-go/README.md index 01f9831e7520..85af88a0d079 100644 --- a/internal/client-go/README.md +++ b/internal/client-go/README.md @@ -223,6 +223,7 @@ Class | Method | HTTP request | Description - [UpdateIdentityBody](docs/UpdateIdentityBody.md) - [UpdateLoginFlowBody](docs/UpdateLoginFlowBody.md) - [UpdateLoginFlowWithCodeMethod](docs/UpdateLoginFlowWithCodeMethod.md) + - [UpdateLoginFlowWithIdentifierFirstMethod](docs/UpdateLoginFlowWithIdentifierFirstMethod.md) - [UpdateLoginFlowWithLookupSecretMethod](docs/UpdateLoginFlowWithLookupSecretMethod.md) - [UpdateLoginFlowWithOidcMethod](docs/UpdateLoginFlowWithOidcMethod.md) - [UpdateLoginFlowWithPasskeyMethod](docs/UpdateLoginFlowWithPasskeyMethod.md) diff --git a/internal/client-go/model_identity_credentials.go b/internal/client-go/model_identity_credentials.go index 7ee96800df4b..374d1d6b38c0 100644 --- a/internal/client-go/model_identity_credentials.go +++ b/internal/client-go/model_identity_credentials.go @@ -23,7 +23,7 @@ type IdentityCredentials struct { CreatedAt *time.Time `json:"created_at,omitempty"` // Identifiers represents a list of unique identifiers this credential type matches. Identifiers []string `json:"identifiers,omitempty"` - // Type discriminates between different types of credentials. password CredentialsTypePassword oidc CredentialsTypeOIDC totp CredentialsTypeTOTP lookup_secret CredentialsTypeLookup webauthn CredentialsTypeWebAuthn code CredentialsTypeCodeAuth passkey CredentialsTypePasskey profile CredentialsTypeProfile link_recovery CredentialsTypeRecoveryLink CredentialsTypeRecoveryLink is a special credential type linked to the link strategy (recovery flow). It is not used within the credentials object itself. code_recovery CredentialsTypeRecoveryCode + // Type discriminates between different types of credentials. password CredentialsTypePassword oidc CredentialsTypeOIDC totp CredentialsTypeTOTP lookup_secret CredentialsTypeLookup webauthn CredentialsTypeWebAuthn code CredentialsTypeCodeAuth passkey CredentialsTypePasskey profile CredentialsTypeProfile two_step TwoStep link_recovery CredentialsTypeRecoveryLink CredentialsTypeRecoveryLink is a special credential type linked to the link strategy (recovery flow). It is not used within the credentials object itself. code_recovery CredentialsTypeRecoveryCode Type *string `json:"type,omitempty"` // UpdatedAt is a helper struct field for gobuffalo.pop. UpdatedAt *time.Time `json:"updated_at,omitempty"` diff --git a/internal/client-go/model_login_flow.go b/internal/client-go/model_login_flow.go index 2794adee0b83..dac443b5bbe4 100644 --- a/internal/client-go/model_login_flow.go +++ b/internal/client-go/model_login_flow.go @@ -18,7 +18,7 @@ import ( // LoginFlow This object represents a login flow. A login flow is initiated at the \"Initiate Login API / Browser Flow\" endpoint by a client. Once a login flow is completed successfully, a session cookie or session token will be issued. type LoginFlow struct { - // The active login method If set contains the login method used. If the flow is new, it is unset. password CredentialsTypePassword oidc CredentialsTypeOIDC totp CredentialsTypeTOTP lookup_secret CredentialsTypeLookup webauthn CredentialsTypeWebAuthn code CredentialsTypeCodeAuth passkey CredentialsTypePasskey profile CredentialsTypeProfile link_recovery CredentialsTypeRecoveryLink CredentialsTypeRecoveryLink is a special credential type linked to the link strategy (recovery flow). It is not used within the credentials object itself. code_recovery CredentialsTypeRecoveryCode + // The active login method If set contains the login method used. If the flow is new, it is unset. password CredentialsTypePassword oidc CredentialsTypeOIDC totp CredentialsTypeTOTP lookup_secret CredentialsTypeLookup webauthn CredentialsTypeWebAuthn code CredentialsTypeCodeAuth passkey CredentialsTypePasskey profile CredentialsTypeProfile two_step TwoStep link_recovery CredentialsTypeRecoveryLink CredentialsTypeRecoveryLink is a special credential type linked to the link strategy (recovery flow). It is not used within the credentials object itself. code_recovery CredentialsTypeRecoveryCode Active *string `json:"active,omitempty"` // CreatedAt is a helper struct field for gobuffalo.pop. CreatedAt *time.Time `json:"created_at,omitempty"` diff --git a/internal/client-go/model_registration_flow.go b/internal/client-go/model_registration_flow.go index c0ba64843d3f..c5fe02951e21 100644 --- a/internal/client-go/model_registration_flow.go +++ b/internal/client-go/model_registration_flow.go @@ -18,7 +18,7 @@ import ( // RegistrationFlow struct for RegistrationFlow type RegistrationFlow struct { - // Active, if set, contains the registration method that is being used. It is initially not set. password CredentialsTypePassword oidc CredentialsTypeOIDC totp CredentialsTypeTOTP lookup_secret CredentialsTypeLookup webauthn CredentialsTypeWebAuthn code CredentialsTypeCodeAuth passkey CredentialsTypePasskey profile CredentialsTypeProfile link_recovery CredentialsTypeRecoveryLink CredentialsTypeRecoveryLink is a special credential type linked to the link strategy (recovery flow). It is not used within the credentials object itself. code_recovery CredentialsTypeRecoveryCode + // Active, if set, contains the registration method that is being used. It is initially not set. password CredentialsTypePassword oidc CredentialsTypeOIDC totp CredentialsTypeTOTP lookup_secret CredentialsTypeLookup webauthn CredentialsTypeWebAuthn code CredentialsTypeCodeAuth passkey CredentialsTypePasskey profile CredentialsTypeProfile two_step TwoStep link_recovery CredentialsTypeRecoveryLink CredentialsTypeRecoveryLink is a special credential type linked to the link strategy (recovery flow). It is not used within the credentials object itself. code_recovery CredentialsTypeRecoveryCode Active *string `json:"active,omitempty"` // ExpiresAt is the time (UTC) when the flow expires. If the user still wishes to log in, a new flow has to be initiated. ExpiresAt time.Time `json:"expires_at"` diff --git a/internal/client-go/model_ui_node.go b/internal/client-go/model_ui_node.go index e73f3c5e37d8..3582d9e85f67 100644 --- a/internal/client-go/model_ui_node.go +++ b/internal/client-go/model_ui_node.go @@ -18,7 +18,7 @@ import ( // UiNode Nodes are represented as HTML elements or their native UI equivalents. For example, a node can be an `` tag, or an `` but also `some plain text`. type UiNode struct { Attributes UiNodeAttributes `json:"attributes"` - // Group specifies which group (e.g. password authenticator) this node belongs to. default DefaultGroup password PasswordGroup oidc OpenIDConnectGroup profile ProfileGroup link LinkGroup code CodeGroup totp TOTPGroup lookup_secret LookupGroup webauthn WebAuthnGroup passkey PasskeyGroup + // Group specifies which group (e.g. password authenticator) this node belongs to. default DefaultGroup password PasswordGroup oidc OpenIDConnectGroup profile ProfileGroup link LinkGroup code CodeGroup totp TOTPGroup lookup_secret LookupGroup webauthn WebAuthnGroup passkey PasskeyGroup identifier_first IdentifierFirstGroup Group string `json:"group"` Messages []UiText `json:"messages"` Meta UiNodeMeta `json:"meta"` diff --git a/internal/client-go/model_update_login_flow_body.go b/internal/client-go/model_update_login_flow_body.go index b8bb05734e3c..f0d79322c54f 100644 --- a/internal/client-go/model_update_login_flow_body.go +++ b/internal/client-go/model_update_login_flow_body.go @@ -18,13 +18,14 @@ import ( // UpdateLoginFlowBody - struct for UpdateLoginFlowBody type UpdateLoginFlowBody struct { - UpdateLoginFlowWithCodeMethod *UpdateLoginFlowWithCodeMethod - UpdateLoginFlowWithLookupSecretMethod *UpdateLoginFlowWithLookupSecretMethod - UpdateLoginFlowWithOidcMethod *UpdateLoginFlowWithOidcMethod - UpdateLoginFlowWithPasskeyMethod *UpdateLoginFlowWithPasskeyMethod - UpdateLoginFlowWithPasswordMethod *UpdateLoginFlowWithPasswordMethod - UpdateLoginFlowWithTotpMethod *UpdateLoginFlowWithTotpMethod - UpdateLoginFlowWithWebAuthnMethod *UpdateLoginFlowWithWebAuthnMethod + UpdateLoginFlowWithCodeMethod *UpdateLoginFlowWithCodeMethod + UpdateLoginFlowWithIdentifierFirstMethod *UpdateLoginFlowWithIdentifierFirstMethod + UpdateLoginFlowWithLookupSecretMethod *UpdateLoginFlowWithLookupSecretMethod + UpdateLoginFlowWithOidcMethod *UpdateLoginFlowWithOidcMethod + UpdateLoginFlowWithPasskeyMethod *UpdateLoginFlowWithPasskeyMethod + UpdateLoginFlowWithPasswordMethod *UpdateLoginFlowWithPasswordMethod + UpdateLoginFlowWithTotpMethod *UpdateLoginFlowWithTotpMethod + UpdateLoginFlowWithWebAuthnMethod *UpdateLoginFlowWithWebAuthnMethod } // UpdateLoginFlowWithCodeMethodAsUpdateLoginFlowBody is a convenience function that returns UpdateLoginFlowWithCodeMethod wrapped in UpdateLoginFlowBody @@ -34,6 +35,13 @@ func UpdateLoginFlowWithCodeMethodAsUpdateLoginFlowBody(v *UpdateLoginFlowWithCo } } +// UpdateLoginFlowWithIdentifierFirstMethodAsUpdateLoginFlowBody is a convenience function that returns UpdateLoginFlowWithIdentifierFirstMethod wrapped in UpdateLoginFlowBody +func UpdateLoginFlowWithIdentifierFirstMethodAsUpdateLoginFlowBody(v *UpdateLoginFlowWithIdentifierFirstMethod) UpdateLoginFlowBody { + return UpdateLoginFlowBody{ + UpdateLoginFlowWithIdentifierFirstMethod: v, + } +} + // UpdateLoginFlowWithLookupSecretMethodAsUpdateLoginFlowBody is a convenience function that returns UpdateLoginFlowWithLookupSecretMethod wrapped in UpdateLoginFlowBody func UpdateLoginFlowWithLookupSecretMethodAsUpdateLoginFlowBody(v *UpdateLoginFlowWithLookupSecretMethod) UpdateLoginFlowBody { return UpdateLoginFlowBody{ @@ -98,6 +106,18 @@ func (dst *UpdateLoginFlowBody) UnmarshalJSON(data []byte) error { } } + // check if the discriminator value is 'identifier_first' + if jsonDict["method"] == "identifier_first" { + // try to unmarshal JSON data into UpdateLoginFlowWithIdentifierFirstMethod + err = json.Unmarshal(data, &dst.UpdateLoginFlowWithIdentifierFirstMethod) + if err == nil { + return nil // data stored in dst.UpdateLoginFlowWithIdentifierFirstMethod, return on the first match + } else { + dst.UpdateLoginFlowWithIdentifierFirstMethod = nil + return fmt.Errorf("Failed to unmarshal UpdateLoginFlowBody as UpdateLoginFlowWithIdentifierFirstMethod: %s", err.Error()) + } + } + // check if the discriminator value is 'lookup_secret' if jsonDict["method"] == "lookup_secret" { // try to unmarshal JSON data into UpdateLoginFlowWithLookupSecretMethod @@ -182,6 +202,18 @@ func (dst *UpdateLoginFlowBody) UnmarshalJSON(data []byte) error { } } + // check if the discriminator value is 'updateLoginFlowWithIdentifierFirstMethod' + if jsonDict["method"] == "updateLoginFlowWithIdentifierFirstMethod" { + // try to unmarshal JSON data into UpdateLoginFlowWithIdentifierFirstMethod + err = json.Unmarshal(data, &dst.UpdateLoginFlowWithIdentifierFirstMethod) + if err == nil { + return nil // data stored in dst.UpdateLoginFlowWithIdentifierFirstMethod, return on the first match + } else { + dst.UpdateLoginFlowWithIdentifierFirstMethod = nil + return fmt.Errorf("Failed to unmarshal UpdateLoginFlowBody as UpdateLoginFlowWithIdentifierFirstMethod: %s", err.Error()) + } + } + // check if the discriminator value is 'updateLoginFlowWithLookupSecretMethod' if jsonDict["method"] == "updateLoginFlowWithLookupSecretMethod" { // try to unmarshal JSON data into UpdateLoginFlowWithLookupSecretMethod @@ -263,6 +295,10 @@ func (src UpdateLoginFlowBody) MarshalJSON() ([]byte, error) { return json.Marshal(&src.UpdateLoginFlowWithCodeMethod) } + if src.UpdateLoginFlowWithIdentifierFirstMethod != nil { + return json.Marshal(&src.UpdateLoginFlowWithIdentifierFirstMethod) + } + if src.UpdateLoginFlowWithLookupSecretMethod != nil { return json.Marshal(&src.UpdateLoginFlowWithLookupSecretMethod) } @@ -299,6 +335,10 @@ func (obj *UpdateLoginFlowBody) GetActualInstance() interface{} { return obj.UpdateLoginFlowWithCodeMethod } + if obj.UpdateLoginFlowWithIdentifierFirstMethod != nil { + return obj.UpdateLoginFlowWithIdentifierFirstMethod + } + if obj.UpdateLoginFlowWithLookupSecretMethod != nil { return obj.UpdateLoginFlowWithLookupSecretMethod } diff --git a/internal/client-go/model_update_login_flow_with_identifier_first_method.go b/internal/client-go/model_update_login_flow_with_identifier_first_method.go new file mode 100644 index 000000000000..70cf8002990d --- /dev/null +++ b/internal/client-go/model_update_login_flow_with_identifier_first_method.go @@ -0,0 +1,212 @@ +/* + * Ory Identities API + * + * This is the API specification for Ory Identities with features such as registration, login, recovery, account verification, profile settings, password reset, identity management, session management, email and sms delivery, and more. + * + * API version: + * Contact: office@ory.sh + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "encoding/json" +) + +// UpdateLoginFlowWithIdentifierFirstMethod Update Login Flow with Multi-Step Method +type UpdateLoginFlowWithIdentifierFirstMethod struct { + // Sending the anti-csrf token is only required for browser login flows. + CsrfToken *string `json:"csrf_token,omitempty"` + // Identifier is the email or username of the user trying to log in. + Identifier string `json:"identifier"` + // Method should be set to \"password\" when logging in using the identifier and password strategy. + Method string `json:"method"` + // Transient data to pass along to any webhooks + TransientPayload map[string]interface{} `json:"transient_payload,omitempty"` +} + +// NewUpdateLoginFlowWithIdentifierFirstMethod instantiates a new UpdateLoginFlowWithIdentifierFirstMethod object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewUpdateLoginFlowWithIdentifierFirstMethod(identifier string, method string) *UpdateLoginFlowWithIdentifierFirstMethod { + this := UpdateLoginFlowWithIdentifierFirstMethod{} + this.Identifier = identifier + this.Method = method + return &this +} + +// NewUpdateLoginFlowWithIdentifierFirstMethodWithDefaults instantiates a new UpdateLoginFlowWithIdentifierFirstMethod object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewUpdateLoginFlowWithIdentifierFirstMethodWithDefaults() *UpdateLoginFlowWithIdentifierFirstMethod { + this := UpdateLoginFlowWithIdentifierFirstMethod{} + return &this +} + +// GetCsrfToken returns the CsrfToken field value if set, zero value otherwise. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) GetCsrfToken() string { + if o == nil || o.CsrfToken == nil { + var ret string + return ret + } + return *o.CsrfToken +} + +// GetCsrfTokenOk returns a tuple with the CsrfToken field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) GetCsrfTokenOk() (*string, bool) { + if o == nil || o.CsrfToken == nil { + return nil, false + } + return o.CsrfToken, true +} + +// HasCsrfToken returns a boolean if a field has been set. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) HasCsrfToken() bool { + if o != nil && o.CsrfToken != nil { + return true + } + + return false +} + +// SetCsrfToken gets a reference to the given string and assigns it to the CsrfToken field. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) SetCsrfToken(v string) { + o.CsrfToken = &v +} + +// GetIdentifier returns the Identifier field value +func (o *UpdateLoginFlowWithIdentifierFirstMethod) GetIdentifier() string { + if o == nil { + var ret string + return ret + } + + return o.Identifier +} + +// GetIdentifierOk returns a tuple with the Identifier field value +// and a boolean to check if the value has been set. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) GetIdentifierOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Identifier, true +} + +// SetIdentifier sets field value +func (o *UpdateLoginFlowWithIdentifierFirstMethod) SetIdentifier(v string) { + o.Identifier = v +} + +// GetMethod returns the Method field value +func (o *UpdateLoginFlowWithIdentifierFirstMethod) GetMethod() string { + if o == nil { + var ret string + return ret + } + + return o.Method +} + +// GetMethodOk returns a tuple with the Method field value +// and a boolean to check if the value has been set. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) GetMethodOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Method, true +} + +// SetMethod sets field value +func (o *UpdateLoginFlowWithIdentifierFirstMethod) SetMethod(v string) { + o.Method = v +} + +// GetTransientPayload returns the TransientPayload field value if set, zero value otherwise. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) GetTransientPayload() map[string]interface{} { + if o == nil || o.TransientPayload == nil { + var ret map[string]interface{} + return ret + } + return o.TransientPayload +} + +// GetTransientPayloadOk returns a tuple with the TransientPayload field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) GetTransientPayloadOk() (map[string]interface{}, bool) { + if o == nil || o.TransientPayload == nil { + return nil, false + } + return o.TransientPayload, true +} + +// HasTransientPayload returns a boolean if a field has been set. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) HasTransientPayload() bool { + if o != nil && o.TransientPayload != nil { + return true + } + + return false +} + +// SetTransientPayload gets a reference to the given map[string]interface{} and assigns it to the TransientPayload field. +func (o *UpdateLoginFlowWithIdentifierFirstMethod) SetTransientPayload(v map[string]interface{}) { + o.TransientPayload = v +} + +func (o UpdateLoginFlowWithIdentifierFirstMethod) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.CsrfToken != nil { + toSerialize["csrf_token"] = o.CsrfToken + } + if true { + toSerialize["identifier"] = o.Identifier + } + if true { + toSerialize["method"] = o.Method + } + if o.TransientPayload != nil { + toSerialize["transient_payload"] = o.TransientPayload + } + return json.Marshal(toSerialize) +} + +type NullableUpdateLoginFlowWithIdentifierFirstMethod struct { + value *UpdateLoginFlowWithIdentifierFirstMethod + isSet bool +} + +func (v NullableUpdateLoginFlowWithIdentifierFirstMethod) Get() *UpdateLoginFlowWithIdentifierFirstMethod { + return v.value +} + +func (v *NullableUpdateLoginFlowWithIdentifierFirstMethod) Set(val *UpdateLoginFlowWithIdentifierFirstMethod) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateLoginFlowWithIdentifierFirstMethod) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateLoginFlowWithIdentifierFirstMethod) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateLoginFlowWithIdentifierFirstMethod(val *UpdateLoginFlowWithIdentifierFirstMethod) *NullableUpdateLoginFlowWithIdentifierFirstMethod { + return &NullableUpdateLoginFlowWithIdentifierFirstMethod{value: val, isSet: true} +} + +func (v NullableUpdateLoginFlowWithIdentifierFirstMethod) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateLoginFlowWithIdentifierFirstMethod) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/driver.go b/internal/driver.go index c10134347bd3..00c86108a397 100644 --- a/internal/driver.go +++ b/internal/driver.go @@ -42,18 +42,18 @@ func init() { func NewConfigurationWithDefaults(t testing.TB, opts ...configx.OptionModifier) *config.Config { configOpts := append([]configx.OptionModifier{ configx.WithValues(map[string]interface{}{ - "log.level": "error", - config.ViperKeyDSN: dbal.NewSQLiteTestDatabase(t), - config.ViperKeyHasherArgon2ConfigMemory: 16384, - config.ViperKeyHasherArgon2ConfigIterations: 1, - config.ViperKeyHasherArgon2ConfigParallelism: 1, - config.ViperKeyHasherArgon2ConfigSaltLength: 16, - config.ViperKeyHasherBcryptCost: 4, - config.ViperKeyHasherArgon2ConfigKeyLength: 16, - config.ViperKeyCourierSMTPURL: "smtp://foo:bar@baz.com/", - config.ViperKeySelfServiceBrowserDefaultReturnTo: "https://www.ory.sh/redirect-not-set", - config.ViperKeySecretsCipher: []string{"secret-thirty-two-character-long"}, - config.ViperKeySelfServiceLoginFlowTwoStepEnabled: false, + "log.level": "error", + config.ViperKeyDSN: dbal.NewSQLiteTestDatabase(t), + config.ViperKeyHasherArgon2ConfigMemory: 16384, + config.ViperKeyHasherArgon2ConfigIterations: 1, + config.ViperKeyHasherArgon2ConfigParallelism: 1, + config.ViperKeyHasherArgon2ConfigSaltLength: 16, + config.ViperKeyHasherBcryptCost: 4, + config.ViperKeyHasherArgon2ConfigKeyLength: 16, + config.ViperKeyCourierSMTPURL: "smtp://foo:bar@baz.com/", + config.ViperKeySelfServiceBrowserDefaultReturnTo: "https://www.ory.sh/redirect-not-set", + config.ViperKeySecretsCipher: []string{"secret-thirty-two-character-long"}, + config.ViperKeySelfServiceLoginFlowStyle: "one_step", }), configx.SkipValidation(), }, opts...) diff --git a/internal/httpclient/.gitignore b/internal/httpclient/.gitignore new file mode 100644 index 000000000000..daf913b1b347 --- /dev/null +++ b/internal/httpclient/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/internal/httpclient/.openapi-generator-ignore b/internal/httpclient/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/internal/httpclient/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/internal/httpclient/.openapi-generator/FILES b/internal/httpclient/.openapi-generator/FILES new file mode 100644 index 000000000000..c573997505d8 --- /dev/null +++ b/internal/httpclient/.openapi-generator/FILES @@ -0,0 +1,262 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +api_courier.go +api_frontend.go +api_identity.go +api_metadata.go +client.go +configuration.go +docs/AuthenticatorAssuranceLevel.md +docs/BatchPatchIdentitiesResponse.md +docs/ConsistencyRequestParameters.md +docs/ContinueWith.md +docs/ContinueWithRecoveryUi.md +docs/ContinueWithRecoveryUiFlow.md +docs/ContinueWithRedirectBrowserTo.md +docs/ContinueWithSetOrySessionToken.md +docs/ContinueWithSettingsUi.md +docs/ContinueWithSettingsUiFlow.md +docs/ContinueWithVerificationUi.md +docs/ContinueWithVerificationUiFlow.md +docs/CourierApi.md +docs/CourierMessageStatus.md +docs/CourierMessageType.md +docs/CreateIdentityBody.md +docs/CreateRecoveryCodeForIdentityBody.md +docs/CreateRecoveryLinkForIdentityBody.md +docs/DeleteMySessionsCount.md +docs/ErrorAuthenticatorAssuranceLevelNotSatisfied.md +docs/ErrorBrowserLocationChangeRequired.md +docs/ErrorFlowReplaced.md +docs/ErrorGeneric.md +docs/FlowError.md +docs/FrontendApi.md +docs/GenericError.md +docs/GetVersion200Response.md +docs/HealthNotReadyStatus.md +docs/HealthStatus.md +docs/Identity.md +docs/IdentityApi.md +docs/IdentityCredentials.md +docs/IdentityCredentialsCode.md +docs/IdentityCredentialsOidc.md +docs/IdentityCredentialsOidcProvider.md +docs/IdentityCredentialsPassword.md +docs/IdentityPatch.md +docs/IdentityPatchResponse.md +docs/IdentitySchemaContainer.md +docs/IdentityWithCredentials.md +docs/IdentityWithCredentialsOidc.md +docs/IdentityWithCredentialsOidcConfig.md +docs/IdentityWithCredentialsOidcConfigProvider.md +docs/IdentityWithCredentialsPassword.md +docs/IdentityWithCredentialsPasswordConfig.md +docs/IsAlive200Response.md +docs/IsReady503Response.md +docs/JsonPatch.md +docs/LoginFlow.md +docs/LoginFlowState.md +docs/LogoutFlow.md +docs/Message.md +docs/MessageDispatch.md +docs/MetadataApi.md +docs/NeedsPrivilegedSessionError.md +docs/OAuth2Client.md +docs/OAuth2ConsentRequestOpenIDConnectContext.md +docs/OAuth2LoginRequest.md +docs/PatchIdentitiesBody.md +docs/PerformNativeLogoutBody.md +docs/RecoveryCodeForIdentity.md +docs/RecoveryFlow.md +docs/RecoveryFlowState.md +docs/RecoveryIdentityAddress.md +docs/RecoveryLinkForIdentity.md +docs/RegistrationFlow.md +docs/RegistrationFlowState.md +docs/SelfServiceFlowExpiredError.md +docs/Session.md +docs/SessionAuthenticationMethod.md +docs/SessionDevice.md +docs/SettingsFlow.md +docs/SettingsFlowState.md +docs/SuccessfulCodeExchangeResponse.md +docs/SuccessfulNativeLogin.md +docs/SuccessfulNativeRegistration.md +docs/TokenPagination.md +docs/TokenPaginationHeaders.md +docs/UiContainer.md +docs/UiNode.md +docs/UiNodeAnchorAttributes.md +docs/UiNodeAttributes.md +docs/UiNodeImageAttributes.md +docs/UiNodeInputAttributes.md +docs/UiNodeMeta.md +docs/UiNodeScriptAttributes.md +docs/UiNodeTextAttributes.md +docs/UiText.md +docs/UpdateIdentityBody.md +docs/UpdateLoginFlowBody.md +docs/UpdateLoginFlowWithCodeMethod.md +docs/UpdateLoginFlowWithIdentifierFirstMethod.md +docs/UpdateLoginFlowWithLookupSecretMethod.md +docs/UpdateLoginFlowWithOidcMethod.md +docs/UpdateLoginFlowWithPasskeyMethod.md +docs/UpdateLoginFlowWithPasswordMethod.md +docs/UpdateLoginFlowWithTotpMethod.md +docs/UpdateLoginFlowWithWebAuthnMethod.md +docs/UpdateRecoveryFlowBody.md +docs/UpdateRecoveryFlowWithCodeMethod.md +docs/UpdateRecoveryFlowWithLinkMethod.md +docs/UpdateRegistrationFlowBody.md +docs/UpdateRegistrationFlowWithCodeMethod.md +docs/UpdateRegistrationFlowWithOidcMethod.md +docs/UpdateRegistrationFlowWithPasskeyMethod.md +docs/UpdateRegistrationFlowWithPasswordMethod.md +docs/UpdateRegistrationFlowWithProfileMethod.md +docs/UpdateRegistrationFlowWithWebAuthnMethod.md +docs/UpdateSettingsFlowBody.md +docs/UpdateSettingsFlowWithLookupMethod.md +docs/UpdateSettingsFlowWithOidcMethod.md +docs/UpdateSettingsFlowWithPasskeyMethod.md +docs/UpdateSettingsFlowWithPasswordMethod.md +docs/UpdateSettingsFlowWithProfileMethod.md +docs/UpdateSettingsFlowWithTotpMethod.md +docs/UpdateSettingsFlowWithWebAuthnMethod.md +docs/UpdateVerificationFlowBody.md +docs/UpdateVerificationFlowWithCodeMethod.md +docs/UpdateVerificationFlowWithLinkMethod.md +docs/VerifiableIdentityAddress.md +docs/VerificationFlow.md +docs/VerificationFlowState.md +docs/Version.md +git_push.sh +go.mod +go.sum +model_authenticator_assurance_level.go +model_batch_patch_identities_response.go +model_consistency_request_parameters.go +model_continue_with.go +model_continue_with_recovery_ui.go +model_continue_with_recovery_ui_flow.go +model_continue_with_redirect_browser_to.go +model_continue_with_set_ory_session_token.go +model_continue_with_settings_ui.go +model_continue_with_settings_ui_flow.go +model_continue_with_verification_ui.go +model_continue_with_verification_ui_flow.go +model_courier_message_status.go +model_courier_message_type.go +model_create_identity_body.go +model_create_recovery_code_for_identity_body.go +model_create_recovery_link_for_identity_body.go +model_delete_my_sessions_count.go +model_error_authenticator_assurance_level_not_satisfied.go +model_error_browser_location_change_required.go +model_error_flow_replaced.go +model_error_generic.go +model_flow_error.go +model_generic_error.go +model_get_version_200_response.go +model_health_not_ready_status.go +model_health_status.go +model_identity.go +model_identity_credentials.go +model_identity_credentials_code.go +model_identity_credentials_oidc.go +model_identity_credentials_oidc_provider.go +model_identity_credentials_password.go +model_identity_patch.go +model_identity_patch_response.go +model_identity_schema_container.go +model_identity_with_credentials.go +model_identity_with_credentials_oidc.go +model_identity_with_credentials_oidc_config.go +model_identity_with_credentials_oidc_config_provider.go +model_identity_with_credentials_password.go +model_identity_with_credentials_password_config.go +model_is_alive_200_response.go +model_is_ready_503_response.go +model_json_patch.go +model_login_flow.go +model_login_flow_state.go +model_logout_flow.go +model_message.go +model_message_dispatch.go +model_needs_privileged_session_error.go +model_o_auth2_client.go +model_o_auth2_consent_request_open_id_connect_context.go +model_o_auth2_login_request.go +model_patch_identities_body.go +model_perform_native_logout_body.go +model_recovery_code_for_identity.go +model_recovery_flow.go +model_recovery_flow_state.go +model_recovery_identity_address.go +model_recovery_link_for_identity.go +model_registration_flow.go +model_registration_flow_state.go +model_self_service_flow_expired_error.go +model_session.go +model_session_authentication_method.go +model_session_device.go +model_settings_flow.go +model_settings_flow_state.go +model_successful_code_exchange_response.go +model_successful_native_login.go +model_successful_native_registration.go +model_token_pagination.go +model_token_pagination_headers.go +model_ui_container.go +model_ui_node.go +model_ui_node_anchor_attributes.go +model_ui_node_attributes.go +model_ui_node_image_attributes.go +model_ui_node_input_attributes.go +model_ui_node_meta.go +model_ui_node_script_attributes.go +model_ui_node_text_attributes.go +model_ui_text.go +model_update_identity_body.go +model_update_login_flow_body.go +model_update_login_flow_with_code_method.go +model_update_login_flow_with_identifier_first_method.go +model_update_login_flow_with_lookup_secret_method.go +model_update_login_flow_with_oidc_method.go +model_update_login_flow_with_passkey_method.go +model_update_login_flow_with_password_method.go +model_update_login_flow_with_totp_method.go +model_update_login_flow_with_web_authn_method.go +model_update_recovery_flow_body.go +model_update_recovery_flow_with_code_method.go +model_update_recovery_flow_with_link_method.go +model_update_registration_flow_body.go +model_update_registration_flow_with_code_method.go +model_update_registration_flow_with_oidc_method.go +model_update_registration_flow_with_passkey_method.go +model_update_registration_flow_with_password_method.go +model_update_registration_flow_with_profile_method.go +model_update_registration_flow_with_web_authn_method.go +model_update_settings_flow_body.go +model_update_settings_flow_with_lookup_method.go +model_update_settings_flow_with_oidc_method.go +model_update_settings_flow_with_passkey_method.go +model_update_settings_flow_with_password_method.go +model_update_settings_flow_with_profile_method.go +model_update_settings_flow_with_totp_method.go +model_update_settings_flow_with_web_authn_method.go +model_update_verification_flow_body.go +model_update_verification_flow_with_code_method.go +model_update_verification_flow_with_link_method.go +model_verifiable_identity_address.go +model_verification_flow.go +model_verification_flow_state.go +model_version.go +response.go +test/api_courier_test.go +test/api_frontend_test.go +test/api_identity_test.go +test/api_metadata_test.go +utils.go diff --git a/internal/httpclient/.openapi-generator/VERSION b/internal/httpclient/.openapi-generator/VERSION new file mode 100644 index 000000000000..4b49d9bb63ee --- /dev/null +++ b/internal/httpclient/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.2.0 \ No newline at end of file diff --git a/internal/httpclient/.travis.yml b/internal/httpclient/.travis.yml new file mode 100644 index 000000000000..f5cb2ce9a5aa --- /dev/null +++ b/internal/httpclient/.travis.yml @@ -0,0 +1,8 @@ +language: go + +install: + - go get -d -v . + +script: + - go build -v ./ + diff --git a/internal/httpclient/README.md b/internal/httpclient/README.md new file mode 100644 index 000000000000..85af88a0d079 --- /dev/null +++ b/internal/httpclient/README.md @@ -0,0 +1,292 @@ +# Go API client for client + +This is the API specification for Ory Identities with features such as registration, login, recovery, account verification, profile settings, password reset, identity management, session management, email and sms delivery, and more. + + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. + +- API version: +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.GoClientCodegen + +## Installation + +Install the following dependencies: + +```shell +go get github.com/stretchr/testify/assert +go get golang.org/x/oauth2 +go get golang.org/x/net/context +``` + +Put the package under your project folder and add the following in import: + +```golang +import client "github.com/ory/client-go" +``` + +To use a proxy, set the environment variable `HTTP_PROXY`: + +```golang +os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") +``` + +## Configuration of Server URL + +Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. + +### Select Server Configuration + +For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`. + +```golang +ctx := context.WithValue(context.Background(), client.ContextServerIndex, 1) +``` + +### Templated Server URL + +Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`. + +```golang +ctx := context.WithValue(context.Background(), client.ContextServerVariables, map[string]string{ + "basePath": "v2", +}) +``` + +Note, enum values are always validated and all unused variables are silently ignored. + +### URLs Configuration per Operation + +Each operation can use different server URL defined using `OperationServers` map in the `Configuration`. +An operation is uniquely identifield by `"{classname}Service.{nickname}"` string. +Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps. + +``` +ctx := context.WithValue(context.Background(), client.ContextOperationServerIndices, map[string]int{ + "{classname}Service.{nickname}": 2, +}) +ctx = context.WithValue(context.Background(), client.ContextOperationServerVariables, map[string]map[string]string{ + "{classname}Service.{nickname}": { + "port": "8443", + }, +}) +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*CourierApi* | [**GetCourierMessage**](docs/CourierApi.md#getcouriermessage) | **Get** /admin/courier/messages/{id} | Get a Message +*CourierApi* | [**ListCourierMessages**](docs/CourierApi.md#listcouriermessages) | **Get** /admin/courier/messages | List Messages +*FrontendApi* | [**CreateBrowserLoginFlow**](docs/FrontendApi.md#createbrowserloginflow) | **Get** /self-service/login/browser | Create Login Flow for Browsers +*FrontendApi* | [**CreateBrowserLogoutFlow**](docs/FrontendApi.md#createbrowserlogoutflow) | **Get** /self-service/logout/browser | Create a Logout URL for Browsers +*FrontendApi* | [**CreateBrowserRecoveryFlow**](docs/FrontendApi.md#createbrowserrecoveryflow) | **Get** /self-service/recovery/browser | Create Recovery Flow for Browsers +*FrontendApi* | [**CreateBrowserRegistrationFlow**](docs/FrontendApi.md#createbrowserregistrationflow) | **Get** /self-service/registration/browser | Create Registration Flow for Browsers +*FrontendApi* | [**CreateBrowserSettingsFlow**](docs/FrontendApi.md#createbrowsersettingsflow) | **Get** /self-service/settings/browser | Create Settings Flow for Browsers +*FrontendApi* | [**CreateBrowserVerificationFlow**](docs/FrontendApi.md#createbrowserverificationflow) | **Get** /self-service/verification/browser | Create Verification Flow for Browser Clients +*FrontendApi* | [**CreateNativeLoginFlow**](docs/FrontendApi.md#createnativeloginflow) | **Get** /self-service/login/api | Create Login Flow for Native Apps +*FrontendApi* | [**CreateNativeRecoveryFlow**](docs/FrontendApi.md#createnativerecoveryflow) | **Get** /self-service/recovery/api | Create Recovery Flow for Native Apps +*FrontendApi* | [**CreateNativeRegistrationFlow**](docs/FrontendApi.md#createnativeregistrationflow) | **Get** /self-service/registration/api | Create Registration Flow for Native Apps +*FrontendApi* | [**CreateNativeSettingsFlow**](docs/FrontendApi.md#createnativesettingsflow) | **Get** /self-service/settings/api | Create Settings Flow for Native Apps +*FrontendApi* | [**CreateNativeVerificationFlow**](docs/FrontendApi.md#createnativeverificationflow) | **Get** /self-service/verification/api | Create Verification Flow for Native Apps +*FrontendApi* | [**DisableMyOtherSessions**](docs/FrontendApi.md#disablemyothersessions) | **Delete** /sessions | Disable my other sessions +*FrontendApi* | [**DisableMySession**](docs/FrontendApi.md#disablemysession) | **Delete** /sessions/{id} | Disable one of my sessions +*FrontendApi* | [**ExchangeSessionToken**](docs/FrontendApi.md#exchangesessiontoken) | **Get** /sessions/token-exchange | Exchange Session Token +*FrontendApi* | [**GetFlowError**](docs/FrontendApi.md#getflowerror) | **Get** /self-service/errors | Get User-Flow Errors +*FrontendApi* | [**GetLoginFlow**](docs/FrontendApi.md#getloginflow) | **Get** /self-service/login/flows | Get Login Flow +*FrontendApi* | [**GetRecoveryFlow**](docs/FrontendApi.md#getrecoveryflow) | **Get** /self-service/recovery/flows | Get Recovery Flow +*FrontendApi* | [**GetRegistrationFlow**](docs/FrontendApi.md#getregistrationflow) | **Get** /self-service/registration/flows | Get Registration Flow +*FrontendApi* | [**GetSettingsFlow**](docs/FrontendApi.md#getsettingsflow) | **Get** /self-service/settings/flows | Get Settings Flow +*FrontendApi* | [**GetVerificationFlow**](docs/FrontendApi.md#getverificationflow) | **Get** /self-service/verification/flows | Get Verification Flow +*FrontendApi* | [**GetWebAuthnJavaScript**](docs/FrontendApi.md#getwebauthnjavascript) | **Get** /.well-known/ory/webauthn.js | Get WebAuthn JavaScript +*FrontendApi* | [**ListMySessions**](docs/FrontendApi.md#listmysessions) | **Get** /sessions | Get My Active Sessions +*FrontendApi* | [**PerformNativeLogout**](docs/FrontendApi.md#performnativelogout) | **Delete** /self-service/logout/api | Perform Logout for Native Apps +*FrontendApi* | [**ToSession**](docs/FrontendApi.md#tosession) | **Get** /sessions/whoami | Check Who the Current HTTP Session Belongs To +*FrontendApi* | [**UpdateLoginFlow**](docs/FrontendApi.md#updateloginflow) | **Post** /self-service/login | Submit a Login Flow +*FrontendApi* | [**UpdateLogoutFlow**](docs/FrontendApi.md#updatelogoutflow) | **Get** /self-service/logout | Update Logout Flow +*FrontendApi* | [**UpdateRecoveryFlow**](docs/FrontendApi.md#updaterecoveryflow) | **Post** /self-service/recovery | Update Recovery Flow +*FrontendApi* | [**UpdateRegistrationFlow**](docs/FrontendApi.md#updateregistrationflow) | **Post** /self-service/registration | Update Registration Flow +*FrontendApi* | [**UpdateSettingsFlow**](docs/FrontendApi.md#updatesettingsflow) | **Post** /self-service/settings | Complete Settings Flow +*FrontendApi* | [**UpdateVerificationFlow**](docs/FrontendApi.md#updateverificationflow) | **Post** /self-service/verification | Complete Verification Flow +*IdentityApi* | [**BatchPatchIdentities**](docs/IdentityApi.md#batchpatchidentities) | **Patch** /admin/identities | Create multiple identities +*IdentityApi* | [**CreateIdentity**](docs/IdentityApi.md#createidentity) | **Post** /admin/identities | Create an Identity +*IdentityApi* | [**CreateRecoveryCodeForIdentity**](docs/IdentityApi.md#createrecoverycodeforidentity) | **Post** /admin/recovery/code | Create a Recovery Code +*IdentityApi* | [**CreateRecoveryLinkForIdentity**](docs/IdentityApi.md#createrecoverylinkforidentity) | **Post** /admin/recovery/link | Create a Recovery Link +*IdentityApi* | [**DeleteIdentity**](docs/IdentityApi.md#deleteidentity) | **Delete** /admin/identities/{id} | Delete an Identity +*IdentityApi* | [**DeleteIdentityCredentials**](docs/IdentityApi.md#deleteidentitycredentials) | **Delete** /admin/identities/{id}/credentials/{type} | Delete a credential for a specific identity +*IdentityApi* | [**DeleteIdentitySessions**](docs/IdentityApi.md#deleteidentitysessions) | **Delete** /admin/identities/{id}/sessions | Delete & Invalidate an Identity's Sessions +*IdentityApi* | [**DisableSession**](docs/IdentityApi.md#disablesession) | **Delete** /admin/sessions/{id} | Deactivate a Session +*IdentityApi* | [**ExtendSession**](docs/IdentityApi.md#extendsession) | **Patch** /admin/sessions/{id}/extend | Extend a Session +*IdentityApi* | [**GetIdentity**](docs/IdentityApi.md#getidentity) | **Get** /admin/identities/{id} | Get an Identity +*IdentityApi* | [**GetIdentitySchema**](docs/IdentityApi.md#getidentityschema) | **Get** /schemas/{id} | Get Identity JSON Schema +*IdentityApi* | [**GetSession**](docs/IdentityApi.md#getsession) | **Get** /admin/sessions/{id} | Get Session +*IdentityApi* | [**ListIdentities**](docs/IdentityApi.md#listidentities) | **Get** /admin/identities | List Identities +*IdentityApi* | [**ListIdentitySchemas**](docs/IdentityApi.md#listidentityschemas) | **Get** /schemas | Get all Identity Schemas +*IdentityApi* | [**ListIdentitySessions**](docs/IdentityApi.md#listidentitysessions) | **Get** /admin/identities/{id}/sessions | List an Identity's Sessions +*IdentityApi* | [**ListSessions**](docs/IdentityApi.md#listsessions) | **Get** /admin/sessions | List All Sessions +*IdentityApi* | [**PatchIdentity**](docs/IdentityApi.md#patchidentity) | **Patch** /admin/identities/{id} | Patch an Identity +*IdentityApi* | [**UpdateIdentity**](docs/IdentityApi.md#updateidentity) | **Put** /admin/identities/{id} | Update an Identity +*MetadataApi* | [**GetVersion**](docs/MetadataApi.md#getversion) | **Get** /version | Return Running Software Version. +*MetadataApi* | [**IsAlive**](docs/MetadataApi.md#isalive) | **Get** /health/alive | Check HTTP Server Status +*MetadataApi* | [**IsReady**](docs/MetadataApi.md#isready) | **Get** /health/ready | Check HTTP Server and Database Status + + +## Documentation For Models + + - [AuthenticatorAssuranceLevel](docs/AuthenticatorAssuranceLevel.md) + - [BatchPatchIdentitiesResponse](docs/BatchPatchIdentitiesResponse.md) + - [ConsistencyRequestParameters](docs/ConsistencyRequestParameters.md) + - [ContinueWith](docs/ContinueWith.md) + - [ContinueWithRecoveryUi](docs/ContinueWithRecoveryUi.md) + - [ContinueWithRecoveryUiFlow](docs/ContinueWithRecoveryUiFlow.md) + - [ContinueWithRedirectBrowserTo](docs/ContinueWithRedirectBrowserTo.md) + - [ContinueWithSetOrySessionToken](docs/ContinueWithSetOrySessionToken.md) + - [ContinueWithSettingsUi](docs/ContinueWithSettingsUi.md) + - [ContinueWithSettingsUiFlow](docs/ContinueWithSettingsUiFlow.md) + - [ContinueWithVerificationUi](docs/ContinueWithVerificationUi.md) + - [ContinueWithVerificationUiFlow](docs/ContinueWithVerificationUiFlow.md) + - [CourierMessageStatus](docs/CourierMessageStatus.md) + - [CourierMessageType](docs/CourierMessageType.md) + - [CreateIdentityBody](docs/CreateIdentityBody.md) + - [CreateRecoveryCodeForIdentityBody](docs/CreateRecoveryCodeForIdentityBody.md) + - [CreateRecoveryLinkForIdentityBody](docs/CreateRecoveryLinkForIdentityBody.md) + - [DeleteMySessionsCount](docs/DeleteMySessionsCount.md) + - [ErrorAuthenticatorAssuranceLevelNotSatisfied](docs/ErrorAuthenticatorAssuranceLevelNotSatisfied.md) + - [ErrorBrowserLocationChangeRequired](docs/ErrorBrowserLocationChangeRequired.md) + - [ErrorFlowReplaced](docs/ErrorFlowReplaced.md) + - [ErrorGeneric](docs/ErrorGeneric.md) + - [FlowError](docs/FlowError.md) + - [GenericError](docs/GenericError.md) + - [GetVersion200Response](docs/GetVersion200Response.md) + - [HealthNotReadyStatus](docs/HealthNotReadyStatus.md) + - [HealthStatus](docs/HealthStatus.md) + - [Identity](docs/Identity.md) + - [IdentityCredentials](docs/IdentityCredentials.md) + - [IdentityCredentialsCode](docs/IdentityCredentialsCode.md) + - [IdentityCredentialsOidc](docs/IdentityCredentialsOidc.md) + - [IdentityCredentialsOidcProvider](docs/IdentityCredentialsOidcProvider.md) + - [IdentityCredentialsPassword](docs/IdentityCredentialsPassword.md) + - [IdentityPatch](docs/IdentityPatch.md) + - [IdentityPatchResponse](docs/IdentityPatchResponse.md) + - [IdentitySchemaContainer](docs/IdentitySchemaContainer.md) + - [IdentityWithCredentials](docs/IdentityWithCredentials.md) + - [IdentityWithCredentialsOidc](docs/IdentityWithCredentialsOidc.md) + - [IdentityWithCredentialsOidcConfig](docs/IdentityWithCredentialsOidcConfig.md) + - [IdentityWithCredentialsOidcConfigProvider](docs/IdentityWithCredentialsOidcConfigProvider.md) + - [IdentityWithCredentialsPassword](docs/IdentityWithCredentialsPassword.md) + - [IdentityWithCredentialsPasswordConfig](docs/IdentityWithCredentialsPasswordConfig.md) + - [IsAlive200Response](docs/IsAlive200Response.md) + - [IsReady503Response](docs/IsReady503Response.md) + - [JsonPatch](docs/JsonPatch.md) + - [LoginFlow](docs/LoginFlow.md) + - [LoginFlowState](docs/LoginFlowState.md) + - [LogoutFlow](docs/LogoutFlow.md) + - [Message](docs/Message.md) + - [MessageDispatch](docs/MessageDispatch.md) + - [NeedsPrivilegedSessionError](docs/NeedsPrivilegedSessionError.md) + - [OAuth2Client](docs/OAuth2Client.md) + - [OAuth2ConsentRequestOpenIDConnectContext](docs/OAuth2ConsentRequestOpenIDConnectContext.md) + - [OAuth2LoginRequest](docs/OAuth2LoginRequest.md) + - [PatchIdentitiesBody](docs/PatchIdentitiesBody.md) + - [PerformNativeLogoutBody](docs/PerformNativeLogoutBody.md) + - [RecoveryCodeForIdentity](docs/RecoveryCodeForIdentity.md) + - [RecoveryFlow](docs/RecoveryFlow.md) + - [RecoveryFlowState](docs/RecoveryFlowState.md) + - [RecoveryIdentityAddress](docs/RecoveryIdentityAddress.md) + - [RecoveryLinkForIdentity](docs/RecoveryLinkForIdentity.md) + - [RegistrationFlow](docs/RegistrationFlow.md) + - [RegistrationFlowState](docs/RegistrationFlowState.md) + - [SelfServiceFlowExpiredError](docs/SelfServiceFlowExpiredError.md) + - [Session](docs/Session.md) + - [SessionAuthenticationMethod](docs/SessionAuthenticationMethod.md) + - [SessionDevice](docs/SessionDevice.md) + - [SettingsFlow](docs/SettingsFlow.md) + - [SettingsFlowState](docs/SettingsFlowState.md) + - [SuccessfulCodeExchangeResponse](docs/SuccessfulCodeExchangeResponse.md) + - [SuccessfulNativeLogin](docs/SuccessfulNativeLogin.md) + - [SuccessfulNativeRegistration](docs/SuccessfulNativeRegistration.md) + - [TokenPagination](docs/TokenPagination.md) + - [TokenPaginationHeaders](docs/TokenPaginationHeaders.md) + - [UiContainer](docs/UiContainer.md) + - [UiNode](docs/UiNode.md) + - [UiNodeAnchorAttributes](docs/UiNodeAnchorAttributes.md) + - [UiNodeAttributes](docs/UiNodeAttributes.md) + - [UiNodeImageAttributes](docs/UiNodeImageAttributes.md) + - [UiNodeInputAttributes](docs/UiNodeInputAttributes.md) + - [UiNodeMeta](docs/UiNodeMeta.md) + - [UiNodeScriptAttributes](docs/UiNodeScriptAttributes.md) + - [UiNodeTextAttributes](docs/UiNodeTextAttributes.md) + - [UiText](docs/UiText.md) + - [UpdateIdentityBody](docs/UpdateIdentityBody.md) + - [UpdateLoginFlowBody](docs/UpdateLoginFlowBody.md) + - [UpdateLoginFlowWithCodeMethod](docs/UpdateLoginFlowWithCodeMethod.md) + - [UpdateLoginFlowWithIdentifierFirstMethod](docs/UpdateLoginFlowWithIdentifierFirstMethod.md) + - [UpdateLoginFlowWithLookupSecretMethod](docs/UpdateLoginFlowWithLookupSecretMethod.md) + - [UpdateLoginFlowWithOidcMethod](docs/UpdateLoginFlowWithOidcMethod.md) + - [UpdateLoginFlowWithPasskeyMethod](docs/UpdateLoginFlowWithPasskeyMethod.md) + - [UpdateLoginFlowWithPasswordMethod](docs/UpdateLoginFlowWithPasswordMethod.md) + - [UpdateLoginFlowWithTotpMethod](docs/UpdateLoginFlowWithTotpMethod.md) + - [UpdateLoginFlowWithWebAuthnMethod](docs/UpdateLoginFlowWithWebAuthnMethod.md) + - [UpdateRecoveryFlowBody](docs/UpdateRecoveryFlowBody.md) + - [UpdateRecoveryFlowWithCodeMethod](docs/UpdateRecoveryFlowWithCodeMethod.md) + - [UpdateRecoveryFlowWithLinkMethod](docs/UpdateRecoveryFlowWithLinkMethod.md) + - [UpdateRegistrationFlowBody](docs/UpdateRegistrationFlowBody.md) + - [UpdateRegistrationFlowWithCodeMethod](docs/UpdateRegistrationFlowWithCodeMethod.md) + - [UpdateRegistrationFlowWithOidcMethod](docs/UpdateRegistrationFlowWithOidcMethod.md) + - [UpdateRegistrationFlowWithPasskeyMethod](docs/UpdateRegistrationFlowWithPasskeyMethod.md) + - [UpdateRegistrationFlowWithPasswordMethod](docs/UpdateRegistrationFlowWithPasswordMethod.md) + - [UpdateRegistrationFlowWithProfileMethod](docs/UpdateRegistrationFlowWithProfileMethod.md) + - [UpdateRegistrationFlowWithWebAuthnMethod](docs/UpdateRegistrationFlowWithWebAuthnMethod.md) + - [UpdateSettingsFlowBody](docs/UpdateSettingsFlowBody.md) + - [UpdateSettingsFlowWithLookupMethod](docs/UpdateSettingsFlowWithLookupMethod.md) + - [UpdateSettingsFlowWithOidcMethod](docs/UpdateSettingsFlowWithOidcMethod.md) + - [UpdateSettingsFlowWithPasskeyMethod](docs/UpdateSettingsFlowWithPasskeyMethod.md) + - [UpdateSettingsFlowWithPasswordMethod](docs/UpdateSettingsFlowWithPasswordMethod.md) + - [UpdateSettingsFlowWithProfileMethod](docs/UpdateSettingsFlowWithProfileMethod.md) + - [UpdateSettingsFlowWithTotpMethod](docs/UpdateSettingsFlowWithTotpMethod.md) + - [UpdateSettingsFlowWithWebAuthnMethod](docs/UpdateSettingsFlowWithWebAuthnMethod.md) + - [UpdateVerificationFlowBody](docs/UpdateVerificationFlowBody.md) + - [UpdateVerificationFlowWithCodeMethod](docs/UpdateVerificationFlowWithCodeMethod.md) + - [UpdateVerificationFlowWithLinkMethod](docs/UpdateVerificationFlowWithLinkMethod.md) + - [VerifiableIdentityAddress](docs/VerifiableIdentityAddress.md) + - [VerificationFlow](docs/VerificationFlow.md) + - [VerificationFlowState](docs/VerificationFlowState.md) + - [Version](docs/Version.md) + + +## Documentation For Authorization + + + +### oryAccessToken + +- **Type**: API key +- **API key parameter name**: Authorization +- **Location**: HTTP header + +Note, each API key must be added to a map of `map[string]APIKey` where the key is: Authorization and passed in as the auth context for each request. + + +## Documentation for Utility Methods + +Due to the fact that model structure members are all pointers, this package contains +a number of utility functions to easily obtain pointers to values of basic types. +Each of these functions takes a value of the given basic type and returns a pointer to it: + +* `PtrBool` +* `PtrInt` +* `PtrInt32` +* `PtrInt64` +* `PtrFloat` +* `PtrFloat32` +* `PtrFloat64` +* `PtrString` +* `PtrTime` + +## Author + +office@ory.sh + diff --git a/internal/httpclient/api_courier.go b/internal/httpclient/api_courier.go new file mode 100644 index 000000000000..91bcc08025eb --- /dev/null +++ b/internal/httpclient/api_courier.go @@ -0,0 +1,362 @@ +/* + * Ory Identities API + * + * This is the API specification for Ory Identities with features such as registration, login, recovery, account verification, profile settings, password reset, identity management, session management, email and sms delivery, and more. + * + * API version: + * Contact: office@ory.sh + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// Linger please +var ( + _ context.Context +) + +type CourierApi interface { + + /* + * GetCourierMessage Get a Message + * Gets a specific messages by the given ID. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param id MessageID is the ID of the message. + * @return CourierApiApiGetCourierMessageRequest + */ + GetCourierMessage(ctx context.Context, id string) CourierApiApiGetCourierMessageRequest + + /* + * GetCourierMessageExecute executes the request + * @return Message + */ + GetCourierMessageExecute(r CourierApiApiGetCourierMessageRequest) (*Message, *http.Response, error) + + /* + * ListCourierMessages List Messages + * Lists all messages by given status and recipient. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return CourierApiApiListCourierMessagesRequest + */ + ListCourierMessages(ctx context.Context) CourierApiApiListCourierMessagesRequest + + /* + * ListCourierMessagesExecute executes the request + * @return []Message + */ + ListCourierMessagesExecute(r CourierApiApiListCourierMessagesRequest) ([]Message, *http.Response, error) +} + +// CourierApiService CourierApi service +type CourierApiService service + +type CourierApiApiGetCourierMessageRequest struct { + ctx context.Context + ApiService CourierApi + id string +} + +func (r CourierApiApiGetCourierMessageRequest) Execute() (*Message, *http.Response, error) { + return r.ApiService.GetCourierMessageExecute(r) +} + +/* + * GetCourierMessage Get a Message + * Gets a specific messages by the given ID. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param id MessageID is the ID of the message. + * @return CourierApiApiGetCourierMessageRequest + */ +func (a *CourierApiService) GetCourierMessage(ctx context.Context, id string) CourierApiApiGetCourierMessageRequest { + return CourierApiApiGetCourierMessageRequest{ + ApiService: a, + ctx: ctx, + id: id, + } +} + +/* + * Execute executes the request + * @return Message + */ +func (a *CourierApiService) GetCourierMessageExecute(r CourierApiApiGetCourierMessageRequest) (*Message, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue *Message + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CourierApiService.GetCourierMessage") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/admin/courier/messages/{id}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterToString(r.id, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["oryAccessToken"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(io.LimitReader(localVarHTTPResponse.Body, 1024*1024)) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v ErrorGeneric + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v ErrorGeneric + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type CourierApiApiListCourierMessagesRequest struct { + ctx context.Context + ApiService CourierApi + pageSize *int64 + pageToken *string + status *CourierMessageStatus + recipient *string +} + +func (r CourierApiApiListCourierMessagesRequest) PageSize(pageSize int64) CourierApiApiListCourierMessagesRequest { + r.pageSize = &pageSize + return r +} +func (r CourierApiApiListCourierMessagesRequest) PageToken(pageToken string) CourierApiApiListCourierMessagesRequest { + r.pageToken = &pageToken + return r +} +func (r CourierApiApiListCourierMessagesRequest) Status(status CourierMessageStatus) CourierApiApiListCourierMessagesRequest { + r.status = &status + return r +} +func (r CourierApiApiListCourierMessagesRequest) Recipient(recipient string) CourierApiApiListCourierMessagesRequest { + r.recipient = &recipient + return r +} + +func (r CourierApiApiListCourierMessagesRequest) Execute() ([]Message, *http.Response, error) { + return r.ApiService.ListCourierMessagesExecute(r) +} + +/* + * ListCourierMessages List Messages + * Lists all messages by given status and recipient. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return CourierApiApiListCourierMessagesRequest + */ +func (a *CourierApiService) ListCourierMessages(ctx context.Context) CourierApiApiListCourierMessagesRequest { + return CourierApiApiListCourierMessagesRequest{ + ApiService: a, + ctx: ctx, + } +} + +/* + * Execute executes the request + * @return []Message + */ +func (a *CourierApiService) ListCourierMessagesExecute(r CourierApiApiListCourierMessagesRequest) ([]Message, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []Message + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "CourierApiService.ListCourierMessages") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/admin/courier/messages" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.pageSize != nil { + localVarQueryParams.Add("page_size", parameterToString(*r.pageSize, "")) + } + if r.pageToken != nil { + localVarQueryParams.Add("page_token", parameterToString(*r.pageToken, "")) + } + if r.status != nil { + localVarQueryParams.Add("status", parameterToString(*r.status, "")) + } + if r.recipient != nil { + localVarQueryParams.Add("recipient", parameterToString(*r.recipient, "")) + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["oryAccessToken"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(io.LimitReader(localVarHTTPResponse.Body, 1024*1024)) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v ErrorGeneric + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + var v ErrorGeneric + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/internal/httpclient/api_frontend.go b/internal/httpclient/api_frontend.go new file mode 100644 index 000000000000..cfb87b55902a --- /dev/null +++ b/internal/httpclient/api_frontend.go @@ -0,0 +1,5863 @@ +/* + * Ory Identities API + * + * This is the API specification for Ory Identities with features such as registration, login, recovery, account verification, profile settings, password reset, identity management, session management, email and sms delivery, and more. + * + * API version: + * Contact: office@ory.sh + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// Linger please +var ( + _ context.Context +) + +type FrontendApi interface { + + /* + * CreateBrowserLoginFlow Create Login Flow for Browsers + * This endpoint initializes a browser-based user login flow. This endpoint will set the appropriate + cookies and anti-CSRF measures required for browser-based flows. + + If this endpoint is opened as a link in the browser, it will be redirected to + `selfservice.flows.login.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session + exists already, the browser will be redirected to `urls.default_redirect_url` unless the query parameter + `?refresh=true` was set. + + If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the + case of an error, the `error.id` of the JSON response body can be one of: + + `session_already_available`: The user is already signed in. + `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. + `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. + `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! + + The optional query parameter login_challenge is set when using Kratos with + Hydra in an OAuth2 flow. See the oauth2_provider.url configuration + option. + + This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed. + + More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateBrowserLoginFlowRequest + */ + CreateBrowserLoginFlow(ctx context.Context) FrontendApiApiCreateBrowserLoginFlowRequest + + /* + * CreateBrowserLoginFlowExecute executes the request + * @return LoginFlow + */ + CreateBrowserLoginFlowExecute(r FrontendApiApiCreateBrowserLoginFlowRequest) (*LoginFlow, *http.Response, error) + + /* + * CreateBrowserLogoutFlow Create a Logout URL for Browsers + * This endpoint initializes a browser-based user logout flow and a URL which can be used to log out the user. + + This endpoint is NOT INTENDED for API clients and only works + with browsers (Chrome, Firefox, ...). For API clients you can + call the `/self-service/logout/api` URL directly with the Ory Session Token. + + The URL is only valid for the currently signed in user. If no user is signed in, this endpoint returns + a 401 error. + + When calling this endpoint from a backend, please ensure to properly forward the HTTP cookies. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateBrowserLogoutFlowRequest + */ + CreateBrowserLogoutFlow(ctx context.Context) FrontendApiApiCreateBrowserLogoutFlowRequest + + /* + * CreateBrowserLogoutFlowExecute executes the request + * @return LogoutFlow + */ + CreateBrowserLogoutFlowExecute(r FrontendApiApiCreateBrowserLogoutFlowRequest) (*LogoutFlow, *http.Response, error) + + /* + * CreateBrowserRecoveryFlow Create Recovery Flow for Browsers + * This endpoint initializes a browser-based account recovery flow. Once initialized, the browser will be redirected to + `selfservice.flows.recovery.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session + exists, the browser is returned to the configured return URL. + + If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects + or a 400 bad request error if the user is already authenticated. + + This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed. + + More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateBrowserRecoveryFlowRequest + */ + CreateBrowserRecoveryFlow(ctx context.Context) FrontendApiApiCreateBrowserRecoveryFlowRequest + + /* + * CreateBrowserRecoveryFlowExecute executes the request + * @return RecoveryFlow + */ + CreateBrowserRecoveryFlowExecute(r FrontendApiApiCreateBrowserRecoveryFlowRequest) (*RecoveryFlow, *http.Response, error) + + /* + * CreateBrowserRegistrationFlow Create Registration Flow for Browsers + * This endpoint initializes a browser-based user registration flow. This endpoint will set the appropriate + cookies and anti-CSRF measures required for browser-based flows. + + If this endpoint is opened as a link in the browser, it will be redirected to + `selfservice.flows.registration.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session + exists already, the browser will be redirected to `urls.default_redirect_url`. + + If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the + case of an error, the `error.id` of the JSON response body can be one of: + + `session_already_available`: The user is already signed in. + `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. + `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! + + If this endpoint is called via an AJAX request, the response contains the registration flow without a redirect. + + This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed. + + More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateBrowserRegistrationFlowRequest + */ + CreateBrowserRegistrationFlow(ctx context.Context) FrontendApiApiCreateBrowserRegistrationFlowRequest + + /* + * CreateBrowserRegistrationFlowExecute executes the request + * @return RegistrationFlow + */ + CreateBrowserRegistrationFlowExecute(r FrontendApiApiCreateBrowserRegistrationFlowRequest) (*RegistrationFlow, *http.Response, error) + + /* + * CreateBrowserSettingsFlow Create Settings Flow for Browsers + * This endpoint initializes a browser-based user settings flow. Once initialized, the browser will be redirected to + `selfservice.flows.settings.ui_url` with the flow ID set as the query parameter `?flow=`. If no valid + Ory Kratos Session Cookie is included in the request, a login flow will be initialized. + + If this endpoint is opened as a link in the browser, it will be redirected to + `selfservice.flows.settings.ui_url` with the flow ID set as the query parameter `?flow=`. If no valid user session + was set, the browser will be redirected to the login endpoint. + + If this endpoint is called via an AJAX request, the response contains the settings flow without any redirects + or a 401 forbidden error if no valid session was set. + + Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator + Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn + credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user + to sign in with the second factor (happens automatically for server-side browser flows) or change the configuration. + + If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the + case of an error, the `error.id` of the JSON response body can be one of: + + `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. + `session_inactive`: No Ory Session was found - sign in a user first. + `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! + + This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed. + + More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateBrowserSettingsFlowRequest + */ + CreateBrowserSettingsFlow(ctx context.Context) FrontendApiApiCreateBrowserSettingsFlowRequest + + /* + * CreateBrowserSettingsFlowExecute executes the request + * @return SettingsFlow + */ + CreateBrowserSettingsFlowExecute(r FrontendApiApiCreateBrowserSettingsFlowRequest) (*SettingsFlow, *http.Response, error) + + /* + * CreateBrowserVerificationFlow Create Verification Flow for Browser Clients + * This endpoint initializes a browser-based account verification flow. Once initialized, the browser will be redirected to + `selfservice.flows.verification.ui_url` with the flow ID set as the query parameter `?flow=`. + + If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects. + + This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). + + More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateBrowserVerificationFlowRequest + */ + CreateBrowserVerificationFlow(ctx context.Context) FrontendApiApiCreateBrowserVerificationFlowRequest + + /* + * CreateBrowserVerificationFlowExecute executes the request + * @return VerificationFlow + */ + CreateBrowserVerificationFlowExecute(r FrontendApiApiCreateBrowserVerificationFlowRequest) (*VerificationFlow, *http.Response, error) + + /* + * CreateNativeLoginFlow Create Login Flow for Native Apps + * This endpoint initiates a login flow for native apps that do not use a browser, such as mobile devices, smart TVs, and so on. + + If a valid provided session cookie or session token is provided, a 400 Bad Request error + will be returned unless the URL query parameter `?refresh=true` is set. + + To fetch an existing login flow call `/self-service/login/flows?flow=`. + + You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server + Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make + you vulnerable to a variety of CSRF attacks, including CSRF login attacks. + + In the case of an error, the `error.id` of the JSON response body can be one of: + + `session_already_available`: The user is already signed in. + `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. + `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. + + This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...). + + More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateNativeLoginFlowRequest + */ + CreateNativeLoginFlow(ctx context.Context) FrontendApiApiCreateNativeLoginFlowRequest + + /* + * CreateNativeLoginFlowExecute executes the request + * @return LoginFlow + */ + CreateNativeLoginFlowExecute(r FrontendApiApiCreateNativeLoginFlowRequest) (*LoginFlow, *http.Response, error) + + /* + * CreateNativeRecoveryFlow Create Recovery Flow for Native Apps + * This endpoint initiates a recovery flow for API clients such as mobile devices, smart TVs, and so on. + + If a valid provided session cookie or session token is provided, a 400 Bad Request error. + + On an existing recovery flow, use the `getRecoveryFlow` API endpoint. + + You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server + Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make + you vulnerable to a variety of CSRF attacks. + + This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...). + + More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateNativeRecoveryFlowRequest + */ + CreateNativeRecoveryFlow(ctx context.Context) FrontendApiApiCreateNativeRecoveryFlowRequest + + /* + * CreateNativeRecoveryFlowExecute executes the request + * @return RecoveryFlow + */ + CreateNativeRecoveryFlowExecute(r FrontendApiApiCreateNativeRecoveryFlowRequest) (*RecoveryFlow, *http.Response, error) + + /* + * CreateNativeRegistrationFlow Create Registration Flow for Native Apps + * This endpoint initiates a registration flow for API clients such as mobile devices, smart TVs, and so on. + + If a valid provided session cookie or session token is provided, a 400 Bad Request error + will be returned unless the URL query parameter `?refresh=true` is set. + + To fetch an existing registration flow call `/self-service/registration/flows?flow=`. + + You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server + Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make + you vulnerable to a variety of CSRF attacks. + + In the case of an error, the `error.id` of the JSON response body can be one of: + + `session_already_available`: The user is already signed in. + `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. + + This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...). + + More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateNativeRegistrationFlowRequest + */ + CreateNativeRegistrationFlow(ctx context.Context) FrontendApiApiCreateNativeRegistrationFlowRequest + + /* + * CreateNativeRegistrationFlowExecute executes the request + * @return RegistrationFlow + */ + CreateNativeRegistrationFlowExecute(r FrontendApiApiCreateNativeRegistrationFlowRequest) (*RegistrationFlow, *http.Response, error) + + /* + * CreateNativeSettingsFlow Create Settings Flow for Native Apps + * This endpoint initiates a settings flow for API clients such as mobile devices, smart TVs, and so on. + You must provide a valid Ory Kratos Session Token for this endpoint to respond with HTTP 200 OK. + + To fetch an existing settings flow call `/self-service/settings/flows?flow=`. + + You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server + Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make + you vulnerable to a variety of CSRF attacks. + + Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator + Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn + credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user + to sign in with the second factor or change the configuration. + + In the case of an error, the `error.id` of the JSON response body can be one of: + + `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. + `session_inactive`: No Ory Session was found - sign in a user first. + + This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...). + + More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateNativeSettingsFlowRequest + */ + CreateNativeSettingsFlow(ctx context.Context) FrontendApiApiCreateNativeSettingsFlowRequest + + /* + * CreateNativeSettingsFlowExecute executes the request + * @return SettingsFlow + */ + CreateNativeSettingsFlowExecute(r FrontendApiApiCreateNativeSettingsFlowRequest) (*SettingsFlow, *http.Response, error) + + /* + * CreateNativeVerificationFlow Create Verification Flow for Native Apps + * This endpoint initiates a verification flow for API clients such as mobile devices, smart TVs, and so on. + + To fetch an existing verification flow call `/self-service/verification/flows?flow=`. + + You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server + Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make + you vulnerable to a variety of CSRF attacks. + + This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...). + + More information can be found at [Ory Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiCreateNativeVerificationFlowRequest + */ + CreateNativeVerificationFlow(ctx context.Context) FrontendApiApiCreateNativeVerificationFlowRequest + + /* + * CreateNativeVerificationFlowExecute executes the request + * @return VerificationFlow + */ + CreateNativeVerificationFlowExecute(r FrontendApiApiCreateNativeVerificationFlowRequest) (*VerificationFlow, *http.Response, error) + + /* + * DisableMyOtherSessions Disable my other sessions + * Calling this endpoint invalidates all except the current session that belong to the logged-in user. + Session data are not deleted. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiDisableMyOtherSessionsRequest + */ + DisableMyOtherSessions(ctx context.Context) FrontendApiApiDisableMyOtherSessionsRequest + + /* + * DisableMyOtherSessionsExecute executes the request + * @return DeleteMySessionsCount + */ + DisableMyOtherSessionsExecute(r FrontendApiApiDisableMyOtherSessionsRequest) (*DeleteMySessionsCount, *http.Response, error) + + /* + * DisableMySession Disable one of my sessions + * Calling this endpoint invalidates the specified session. The current session cannot be revoked. + Session data are not deleted. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param id ID is the session's ID. + * @return FrontendApiApiDisableMySessionRequest + */ + DisableMySession(ctx context.Context, id string) FrontendApiApiDisableMySessionRequest + + /* + * DisableMySessionExecute executes the request + */ + DisableMySessionExecute(r FrontendApiApiDisableMySessionRequest) (*http.Response, error) + + /* + * ExchangeSessionToken Exchange Session Token + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiExchangeSessionTokenRequest + */ + ExchangeSessionToken(ctx context.Context) FrontendApiApiExchangeSessionTokenRequest + + /* + * ExchangeSessionTokenExecute executes the request + * @return SuccessfulNativeLogin + */ + ExchangeSessionTokenExecute(r FrontendApiApiExchangeSessionTokenRequest) (*SuccessfulNativeLogin, *http.Response, error) + + /* + * GetFlowError Get User-Flow Errors + * This endpoint returns the error associated with a user-facing self service errors. + + This endpoint supports stub values to help you implement the error UI: + + `?id=stub:500` - returns a stub 500 (Internal Server Error) error. + + More information can be found at [Ory Kratos User User Facing Error Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-facing-errors). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiGetFlowErrorRequest + */ + GetFlowError(ctx context.Context) FrontendApiApiGetFlowErrorRequest + + /* + * GetFlowErrorExecute executes the request + * @return FlowError + */ + GetFlowErrorExecute(r FrontendApiApiGetFlowErrorRequest) (*FlowError, *http.Response, error) + + /* + * GetLoginFlow Get Login Flow + * This endpoint returns a login flow's context with, for example, error details and other information. + + Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. + For AJAX requests you must ensure that cookies are included in the request or requests will fail. + + If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain + and you need to forward the incoming HTTP Cookie header to this endpoint: + + ```js + pseudo-code example + router.get('/login', async function (req, res) { + const flow = await client.getLoginFlow(req.header('cookie'), req.query['flow']) + + res.render('login', flow) + }) + ``` + + This request may fail due to several reasons. The `error.id` can be one of: + + `session_already_available`: The user is already signed in. + `self_service_flow_expired`: The flow is expired and you should request a new one. + + More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiGetLoginFlowRequest + */ + GetLoginFlow(ctx context.Context) FrontendApiApiGetLoginFlowRequest + + /* + * GetLoginFlowExecute executes the request + * @return LoginFlow + */ + GetLoginFlowExecute(r FrontendApiApiGetLoginFlowRequest) (*LoginFlow, *http.Response, error) + + /* + * GetRecoveryFlow Get Recovery Flow + * This endpoint returns a recovery flow's context with, for example, error details and other information. + + Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. + For AJAX requests you must ensure that cookies are included in the request or requests will fail. + + If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain + and you need to forward the incoming HTTP Cookie header to this endpoint: + + ```js + pseudo-code example + router.get('/recovery', async function (req, res) { + const flow = await client.getRecoveryFlow(req.header('Cookie'), req.query['flow']) + + res.render('recovery', flow) + }) + ``` + + More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiGetRecoveryFlowRequest + */ + GetRecoveryFlow(ctx context.Context) FrontendApiApiGetRecoveryFlowRequest + + /* + * GetRecoveryFlowExecute executes the request + * @return RecoveryFlow + */ + GetRecoveryFlowExecute(r FrontendApiApiGetRecoveryFlowRequest) (*RecoveryFlow, *http.Response, error) + + /* + * GetRegistrationFlow Get Registration Flow + * This endpoint returns a registration flow's context with, for example, error details and other information. + + Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. + For AJAX requests you must ensure that cookies are included in the request or requests will fail. + + If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain + and you need to forward the incoming HTTP Cookie header to this endpoint: + + ```js + pseudo-code example + router.get('/registration', async function (req, res) { + const flow = await client.getRegistrationFlow(req.header('cookie'), req.query['flow']) + + res.render('registration', flow) + }) + ``` + + This request may fail due to several reasons. The `error.id` can be one of: + + `session_already_available`: The user is already signed in. + `self_service_flow_expired`: The flow is expired and you should request a new one. + + More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiGetRegistrationFlowRequest + */ + GetRegistrationFlow(ctx context.Context) FrontendApiApiGetRegistrationFlowRequest + + /* + * GetRegistrationFlowExecute executes the request + * @return RegistrationFlow + */ + GetRegistrationFlowExecute(r FrontendApiApiGetRegistrationFlowRequest) (*RegistrationFlow, *http.Response, error) + + /* + * GetSettingsFlow Get Settings Flow + * When accessing this endpoint through Ory Kratos' Public API you must ensure that either the Ory Kratos Session Cookie + or the Ory Kratos Session Token are set. + + Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator + Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn + credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user + to sign in with the second factor or change the configuration. + + You can access this endpoint without credentials when using Ory Kratos' Admin API. + + If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the + case of an error, the `error.id` of the JSON response body can be one of: + + `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. + `session_inactive`: No Ory Session was found - sign in a user first. + `security_identity_mismatch`: The flow was interrupted with `session_refresh_required` but apparently some other + identity logged in instead. + + More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiGetSettingsFlowRequest + */ + GetSettingsFlow(ctx context.Context) FrontendApiApiGetSettingsFlowRequest + + /* + * GetSettingsFlowExecute executes the request + * @return SettingsFlow + */ + GetSettingsFlowExecute(r FrontendApiApiGetSettingsFlowRequest) (*SettingsFlow, *http.Response, error) + + /* + * GetVerificationFlow Get Verification Flow + * This endpoint returns a verification flow's context with, for example, error details and other information. + + Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. + For AJAX requests you must ensure that cookies are included in the request or requests will fail. + + If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain + and you need to forward the incoming HTTP Cookie header to this endpoint: + + ```js + pseudo-code example + router.get('/recovery', async function (req, res) { + const flow = await client.getVerificationFlow(req.header('cookie'), req.query['flow']) + + res.render('verification', flow) + }) + ``` + + More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation). + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @return FrontendApiApiGetVerificationFlowRequest + */ + GetVerificationFlow(ctx context.Context) FrontendApiApiGetVerificationFlowRequest + + /* + * GetVerificationFlowExecute executes the request + * @return VerificationFlow + */ + GetVerificationFlowExecute(r FrontendApiApiGetVerificationFlowRequest) (*VerificationFlow, *http.Response, error) + + /* + * GetWebAuthnJavaScript Get WebAuthn JavaScript + * This endpoint provides JavaScript which is needed in order to perform WebAuthn login and registration. + + If you are building a JavaScript Browser App (e.g. in ReactJS or AngularJS) you will need to load this file: + + ```html +