ory-kratos-0.0.10.0: API bindings for Ory Kratos
Safe HaskellNone
LanguageHaskell2010

OryKratos.API

Synopsis

Client and Server

data Config Source #

Server or client configuration, specifying the host and port to query or serve on.

Constructors

Config 

Fields

Instances

Instances details
Eq Config Source # 
Instance details

Defined in OryKratos.API

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

Ord Config Source # 
Instance details

Defined in OryKratos.API

Read Config Source # 
Instance details

Defined in OryKratos.API

Show Config Source # 
Instance details

Defined in OryKratos.API

data OryKratosBackend m traits metadataAdmin metadataPublic Source #

Configuration, specifying the full url of the service.

Backend for OryKratos. The backend can be used both for the client and the server. The client generated from the OryKratos OpenAPI spec is a backend that executes actions by sending HTTP requests (see createOryKratosClient). Alternatively, provided a backend, the API can be served using runOryKratosMiddlewareServer.

Constructors

OryKratosBackend 

Fields

  • getVersion :: m GetVersion200Response

    This endpoint returns the version of Ory Kratos. If the service supports TLS Edge Termination, this endpoint does not require the `X-Forwarded-Proto` header to be set. Be aware that if you are running multiple nodes of this service, the version will never refer to the cluster state, only to a single instance.

  • isAlive :: m IsAlive200Response

    This endpoint returns a HTTP 200 status code when Ory Kratos is accepting incoming HTTP requests. This status does currently not include checks whether the database connection is working. If the service supports TLS Edge Termination, this endpoint does not require the `X-Forwarded-Proto` header to be set. Be aware that if you are running multiple nodes of this service, the health status will never refer to the cluster state, only to a single instance.

  • isReady :: m IsAlive200Response

    This endpoint returns a HTTP 200 status code when Ory Kratos is up running and the environment dependencies (e.g. the database) are responsive as well. If the service supports TLS Edge Termination, this endpoint does not require the `X-Forwarded-Proto` header to be set. Be aware that if you are running multiple nodes of Ory Kratos, the health status will never refer to the cluster state, only to a single instance.

  • adminCreateIdentity :: AdminCreateIdentityBody -> m (Identity traits metadataAdmin metadataPublic)

    This endpoint creates an identity. Learn how identities work in Ory Kratos' User And Identity Model Documentation.

  • adminCreateSelfServiceRecoveryLink :: AdminCreateSelfServiceRecoveryLinkBody -> m SelfServiceRecoveryLink

    This endpoint creates a recovery link which should be given to the user in order for them to recover (or activate) their account.

  • adminDeleteIdentity :: Text -> m NoContent

    Calling this endpoint irrecoverably and permanently deletes the identity given its ID. This action can not be undone. This endpoint returns 204 when the identity was deleted or when the identity was not found, in which case it is assumed that is has been deleted already. Learn how identities work in Ory Kratos' User And Identity Model Documentation.

  • adminDeleteIdentitySessions :: Text -> m NoContent

    This endpoint is useful for: To forcefully logout Identity from all devices and sessions

  • adminExtendSession :: Text -> m (Session traits metadataAdmin metadataPublic)

    Retrieve the session ID from the `sessionswhoami` endpoint / $sel:toSession:OryKratosBackend SDK method.

  • adminGetIdentity :: Text -> Maybe [Text] -> m (Identity traits metadataAdmin metadataPublic)
  • adminListIdentities :: Maybe Integer -> Maybe Integer -> m [Identity traits metadataAdmin metadataPublic]

    Lists all identities. Does not support search at the moment. Learn how identities work in Ory Kratos' User And Identity Model Documentation.

  • adminListIdentitySessions :: Text -> Maybe Integer -> Maybe Integer -> Maybe Bool -> m [Session traits metadataAdmin metadataPublic]

    This endpoint is useful for: Listing all sessions that belong to an Identity in an administrative context.

  • adminUpdateIdentity :: Text -> AdminUpdateIdentityBody -> m (Identity traits metadataAdmin metadataPublic)

    This endpoint updates an identity. The full identity payload (except credentials) is expected. This endpoint does not support patching. Learn how identities work in Ory Kratos' User And Identity Model Documentation.

  • createSelfServiceLogoutFlowUrlForBrowsers :: Maybe Text -> m SelfServiceLogoutUrl

    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-servicelogout/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 Prelude.error. When calling this endpoint from a backend, please ensure to properly forward the HTTP cookies.

  • getJsonSchema :: Text -> m Value

    Get a JSON Schema

  • getSelfServiceError :: Maybe Text -> m SelfServiceError

    This endpoint returns the Prelude.error associated with a user-facing self service Prelude.errors. This endpoint supports stub values to help you implement the Prelude.error UI: `?id=stub:500` - returns a stub 500 (Internal Server Error) Prelude.error. More information can be found at Ory Kratos User User Facing Error Documentation.

  • getSelfServiceLoginFlow :: Maybe Text -> Maybe Text -> m SelfServiceLoginFlow

    This endpoint returns a login flow's context with, for example, Prelude.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.getSelfServiceLoginFlow(req.header(cookie), req.query[$sel:flow:SubmitSelfServiceSettingsFlowBody]) 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.shdocskratosself-serviceflowsuser-login) and User Registration Documentation.

  • getSelfServiceRecoveryFlow :: Maybe Text -> Maybe Text -> m SelfServiceRecoveryFlow

    This endpoint returns a recovery flow's context with, for example, Prelude.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.getSelfServiceRecoveryFlow(req.header(Cookie), req.query[$sel:flow:SubmitSelfServiceSettingsFlowBody]) res.render(recovery, flow) }) ``` More information can be found at [Ory Kratos Account Recovery Documentation](..self-serviceflowsaccount-recovery).

  • getSelfServiceRegistrationFlow :: Maybe Text -> Maybe Text -> m SelfServiceRegistrationFlow

    This endpoint returns a registration flow's context with, for example, Prelude.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.getSelfServiceRegistrationFlow(req.header(cookie), req.query[$sel:flow:SubmitSelfServiceSettingsFlowBody]) 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.shdocskratosself-serviceflowsuser-login) and User Registration Documentation.

  • getSelfServiceSettingsFlow :: Maybe Text -> Maybe Text -> Maybe Text -> m (SelfServiceSettingsFlow traits metadataAdmin metadataPublic)

    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 Prelude.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 Prelude.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 Prelude.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.

  • getSelfServiceVerificationFlow :: Maybe Text -> Maybe Text -> m SelfServiceVerificationFlow

    This endpoint returns a verification flow's context with, for example, Prelude.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.getSelfServiceVerificationFlow(req.header(cookie), req.query[$sel:flow:SubmitSelfServiceSettingsFlowBody]) res.render(verification, flow) }) More information can be found at [Ory Kratos Email and Phone Verification Documentation](https:www.ory.shdocskratosselfserviceflowsverify-email-account-activation).

  • getWebAuthnJavaScript :: m Text

    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 src="https://public-kratos.example.org/.well-known/ory/webauthn.js" type="script" async / ``` More information can be found at Ory Kratos User Login and User Registration Documentation.

  • initializeSelfServiceLoginFlowForBrowsers :: Maybe Bool -> Maybe Text -> Maybe Text -> m SelfServiceLoginFlow

    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 Prelude.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! 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 and User Registration Documentation.

  • initializeSelfServiceLoginFlowWithoutBrowser :: Maybe Bool -> Maybe Text -> Maybe Text -> m SelfServiceLoginFlow

    This endpoint initiates a login flow for API clients 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 Prelude.error will be returned unless the URL query parameter `?refresh=true` is set. To fetch an existing login flow call `self-serviceloginflows?flow=flow_id`. 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 Prelude.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.shdocskratosself-serviceflowsuser-login) and User Registration Documentation.

  • initializeSelfServiceRecoveryFlowForBrowsers :: Maybe Text -> m SelfServiceRecoveryFlow

    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 Prelude.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.

  • initializeSelfServiceRecoveryFlowWithoutBrowser :: m SelfServiceRecoveryFlow

    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 Prelude.error. To fetch an existing recovery flow call `self-servicerecoveryflows?flow=flow_id`. 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-serviceflowsaccount-recovery).

  • initializeSelfServiceRegistrationFlowForBrowsers :: Maybe Text -> m SelfServiceRegistrationFlow

    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. :::info This endpoint is EXPERIMENTAL and subject to potential breaking changes in the future. ::: 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 Prelude.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 and User Registration Documentation.

  • initializeSelfServiceRegistrationFlowWithoutBrowser :: m SelfServiceRegistrationFlow

    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 Prelude.error will be returned unless the URL query parameter `?refresh=true` is set. To fetch an existing registration flow call `self-serviceregistrationflows?flow=flow_id`. 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 Prelude.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.shdocskratosself-serviceflowsuser-login) and User Registration Documentation.

  • initializeSelfServiceSettingsFlowForBrowsers :: Maybe Text -> m (SelfServiceSettingsFlow traits metadataAdmin metadataPublic)

    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 Prelude.error if no valid session was set. Depending on your configuration this endpoint might return a 403 Prelude.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 Prelude.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 Prelude.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.

  • initializeSelfServiceSettingsFlowWithoutBrowser :: Maybe Text -> m (SelfServiceSettingsFlow traits metadataAdmin metadataPublic)

    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-servicesettingsflows?flow=flow_id`. 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 Prelude.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 Prelude.error occurs, ask the user to sign in with the second factor or change the configuration. In the case of an Prelude.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-serviceflowsuser-settings).

  • initializeSelfServiceVerificationFlowForBrowsers :: Maybe Text -> m SelfServiceVerificationFlow

    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.

  • initializeSelfServiceVerificationFlowWithoutBrowser :: m SelfServiceVerificationFlow

    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-serviceverificationflows?flow=flow_id`. 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 Email and Phone Verification Documentation](https:www.ory.shdocskratosselfserviceflowsverify-email-account-activation).

  • listIdentitySchemas :: Maybe Integer -> Maybe Integer -> m [IdentitySchema]

    Get all Identity Schemas

  • listSessions :: Maybe Integer -> Maybe Integer -> Maybe Text -> Maybe Text -> m [Session traits metadataAdmin metadataPublic]

    This endpoint is useful for: Displaying all other sessions that belong to the logged-in user

  • revokeSession :: Text -> m NoContent

    This endpoint is useful for: To forcefully logout the current user from another device or session

  • revokeSessions :: Maybe Text -> Maybe Text -> m RevokedSessions

    This endpoint is useful for: To forcefully logout the current user from all other devices and sessions

  • submitSelfServiceLoginFlow :: Maybe Text -> SubmitSelfServiceLoginFlowBody -> Maybe Text -> Maybe Text -> m (SuccessfulSelfServiceLoginWithoutBrowser traits metadataAdmin metadataPublic)

    :::info This endpoint is EXPERIMENTAL and subject to potential breaking changes in the future. ::: Use this endpoint to complete a login flow. This endpoint behaves differently for API and browser flows. API flows expect `applicationjson` to be sent in the body and responds with HTTP 200 and a applicationjson body with the session token on success; HTTP 410 if the original flow expired with the appropriate Prelude.error messages set and optionally a $sel:use_flow_id:SelfServiceFlowExpiredError parameter in the body; HTTP 400 on form validation Prelude.errors. Browser flows expect a Content-Type of `applicationx-www-form-urlencoded` or `applicationjson` to be sent in the body and respond with a HTTP 303 redirect to the postafter login URL or the $sel:return_to:SelfServiceLoginFlow value if it was set and if the login succeeded; a HTTP 303 redirect to the login UI URL with the flow ID containing the validation Prelude.errors otherwise. Browser flows with an accept header of `applicationjson` will not redirect but instead respond with HTTP 200 and a applicationjson body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate Prelude.error messages set; HTTP 400 on form validation Prelude.errors. If this endpoint is called with `Accept: applicationjson` in the header, the response contains the flow without a redirect. In the case of an Prelude.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! browser_location_change_required: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows. More information can be found at Ory Kratos User Login and User Registration Documentation.

  • submitSelfServiceLogoutFlow :: Maybe Text -> Maybe Text -> m NoContent

    This endpoint logs out an identity in a self-service manner. If the Accept HTTP header is not set to `applicationjson`, the browser will be redirected (HTTP 303 See Other) to the $sel:return_to:SelfServiceLoginFlow parameter of the initial request or fall back to `urls.default_return_to`. If the Accept HTTP header is set to `applicationjson`, a 204 No Content response will be sent on successful logout instead. This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `self-servicelogoutapi` URL directly with the Ory Session Token. More information can be found at [Ory Kratos User Logout Documentation](https:www.ory.shdocsnextkratosself-serviceflows/user-logout).

  • submitSelfServiceLogoutFlowWithoutBrowser :: SubmitSelfServiceLogoutFlowWithoutBrowserBody -> m NoContent

    Use this endpoint to log out an identity using an Ory Session Token. If the Ory Session Token was successfully revoked, the server returns a 204 No Content response. A 204 No Content response is also sent when the Ory Session Token has been revoked already before. If the Ory Session Token is malformed or does not exist a 403 Forbidden response will be returned. This endpoint does not remove any HTTP Cookies - use the Browser-Based Self-Service Logout Flow instead.

  • submitSelfServiceRecoveryFlow :: Maybe Text -> Maybe Text -> SubmitSelfServiceRecoveryFlowBody -> Maybe Text -> m SelfServiceRecoveryFlow

    Use this endpoint to complete a recovery flow. This endpoint behaves differently for API and browser flows and has several states: choose_method expects $sel:flow:SubmitSelfServiceSettingsFlowBody (in the URL query) and $sel:email:SubmitSelfServiceRecoveryFlowBody (in the body) to be sent and works with API- and Browser-initiated flows. For API clients and Browser clients with HTTP Header `Accept: applicationjson` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid. and a HTTP 303 See Other redirect with a fresh recovery flow if the flow was otherwise invalid (e.g. expired). For Browser clients without HTTP Header Accept or with `Accept: text*` it returns a HTTP 303 See Other redirect to the Recovery UI URL with the Recovery Flow ID appended. sent_email is the success state after choose_method for the $sel:link:SubmitSelfServiceSettingsFlowBody method and allows the user to request another recovery email. It works for both API and Browser-initiated flows and returns the same responses as the flow in choose_method state. passed_challenge expects a token to be sent in the URL query and given the nature of the flow ("sending a recovery link") does not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Recover UI URL with a new Recovery Flow ID which contains an Prelude.error message that the recovery link was invalid. More information can be found at Ory Kratos Account Recovery Documentation.

  • submitSelfServiceRegistrationFlow :: Maybe Text -> SubmitSelfServiceRegistrationFlowBody -> Maybe Text -> m (SuccessfulSelfServiceRegistrationWithoutBrowser traits metadataAdmin metadataPublic)

    Use this endpoint to complete a registration flow by sending an identity's traits and password. This endpoint behaves differently for API and browser flows. API flows expect `applicationjson` to be sent in the body and respond with HTTP 200 and a applicationjson body with the created identity success - if the session hook is configured the $sel:session:SuccessfulSelfServiceLoginWithoutBrowser and $sel:session_token:SuccessfulSelfServiceLoginWithoutBrowser will also be included; HTTP 410 if the original flow expired with the appropriate Prelude.error messages set and optionally a $sel:use_flow_id:SelfServiceFlowExpiredError parameter in the body; HTTP 400 on form validation Prelude.errors. Browser flows expect a Content-Type of `applicationx-www-form-urlencoded` or `applicationjson` to be sent in the body and respond with a HTTP 303 redirect to the postafter registration URL or the $sel:return_to:SelfServiceLoginFlow value if it was set and if the registration succeeded; a HTTP 303 redirect to the registration UI URL with the flow ID containing the validation Prelude.errors otherwise. Browser flows with an accept header of `applicationjson` will not redirect but instead respond with HTTP 200 and a applicationjson body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate Prelude.error messages set; HTTP 400 on form validation Prelude.errors. If this endpoint is called with `Accept: applicationjson` in the header, the response contains the flow without a redirect. In the case of an Prelude.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! browser_location_change_required: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows. More information can be found at Ory Kratos User Login and User Registration Documentation.

  • submitSelfServiceSettingsFlow :: Maybe Text -> SubmitSelfServiceSettingsFlowBody -> Maybe Text -> Maybe Text -> m (SelfServiceSettingsFlow traits metadataAdmin metadataPublic)

    Use this endpoint to complete a settings flow by sending an identity's updated password. This endpoint behaves differently for API and browser flows. API-initiated flows expect `applicationjson` to be sent in the body and respond with HTTP 200 and an applicationjson body with the session token on success; HTTP 303 redirect to a fresh settings flow if the original flow expired with the appropriate Prelude.error messages set; HTTP 400 on form validation Prelude.errors. HTTP 401 when the endpoint is called without a valid session token. HTTP 403 when `selfservice.flows.settings.privileged_session_max_age` was reached or the session's AAL is too low. Implies that the user needs to re-authenticate. Browser flows without HTTP Header Accept or with `Accept: text*` respond with a HTTP 303 redirect to the postafter settings URL or the $sel:return_to:SelfServiceLoginFlow value if it was set and if the flow succeeded; a HTTP 303 redirect to the Settings UI URL with the flow ID containing the validation Prelude.errors otherwise. a HTTP 303 redirect to the login endpoint when `selfservice.flows.settings.privileged_session_max_age` was reached or the session's AAL is too low. Browser flows with HTTP Header `Accept: applicationjson` respond with HTTP 200 and a applicationjson body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate Prelude.error messages set; HTTP 401 when the endpoint is called without a valid session cookie. HTTP 403 when the page is accessed without a session cookie or the session's AAL is too low. HTTP 400 on form validation Prelude.errors. Depending on your configuration this endpoint might return a 403 Prelude.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 Prelude.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 with a `Accept: applicationjson` HTTP header, the response contains the flow without a redirect. In the case of an Prelude.error, the `error.id` of the JSON response body can be one of: session_refresh_required: The identity requested to change something that needs a privileged session. Redirect the identity to the login init endpoint with query parameters `?refresh=true&return_to=the-current-browser-url`, or initiate a refresh login flow otherwise. 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. security_identity_mismatch: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! browser_location_change_required: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows. More information can be found at [Ory Kratos User Settings & Profile Management Documentation](..self-serviceflowsuser-settings).

  • submitSelfServiceVerificationFlow :: Maybe Text -> Maybe Text -> SubmitSelfServiceVerificationFlowBody -> Maybe Text -> m SelfServiceVerificationFlow

    Use this endpoint to complete a verification flow. This endpoint behaves differently for API and browser flows and has several states: choose_method expects $sel:flow:SubmitSelfServiceSettingsFlowBody (in the URL query) and $sel:email:SubmitSelfServiceRecoveryFlowBody (in the body) to be sent and works with API- and Browser-initiated flows. For API clients and Browser clients with HTTP Header `Accept: applicationjson` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid and a HTTP 303 See Other redirect with a fresh verification flow if the flow was otherwise invalid (e.g. expired). For Browser clients without HTTP Header Accept or with `Accept: text*` it returns a HTTP 303 See Other redirect to the Verification UI URL with the Verification Flow ID appended. sent_email is the success state after choose_method when using the $sel:link:SubmitSelfServiceSettingsFlowBody method and allows the user to request another verification email. It works for both API and Browser-initiated flows and returns the same responses as the flow in choose_method state. passed_challenge expects a token to be sent in the URL query and given the nature of the flow ("sending a verification link") does not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Verification UI URL with a new Verification Flow ID which contains an Prelude.error message that the verification link was invalid. More information can be found at Ory Kratos Email and Phone Verification Documentation.

  • toSession :: Maybe Text -> Maybe Text -> m (Session traits metadataAdmin metadataPublic)

    Uses the HTTP Headers in the GET request to determine (e.g. by using checking the cookies) who is authenticated. Returns a session object in the body or 401 if the credentials are invalid or no credentials were sent. Additionally when the request it successful it adds the user ID to the 'X-Kratos-Authenticated-Identity-Id' header in the response. If you call this endpoint from a server-side application, you must forward the HTTP Cookie Header to this endpoint: ```js pseudo-code example router.get('protected-endpoint', async function (req, res) { const session = await client.toSession(undefined, req.header(cookie)) console.log(session) }) ``` When calling this endpoint from a non-browser application (e.g. mobile app) you must include the session token: ```js pseudo-code example ... const session = await client.toSession("the-session-token") console.log(session) ``` Depending on your configuration this endpoint might return a 403 status code 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 Prelude.error occurs, ask the user to sign in with the second factor or change the configuration. This endpoint is useful for: AJAX calls. Remember to send credentials and set up CORS correctly! Reverse proxies and API Gateways Server-side calls - use the `X-Session-Token` header! This endpoint authenticates users by checking if the Cookie HTTP header was set containing an Ory Kratos Session Cookie; if the `Authorization: bearer ory-session-token` HTTP header was set with a valid Ory Kratos Session Token; if the `X-Session-Token` HTTP header was set with a valid Ory Kratos Session Token. If none of these headers are set or the cooke or token are invalid, the endpoint returns a HTTP 401 status code. As explained above, this request may fail due to several reasons. The `error.id` can be one of: session_inactive: No active session was found in the request (e.g. no Ory Session Cookie Ory Session Token). session_aal2_required: An active session was found but it does not fulfil the Authenticator Assurance Level, implying that the session must (e.g.) authenticate the second factor.

createOryKratosClient :: forall traits metadataAdmin metadataPublic. (FromJSON traits, FromJSON metadataAdmin, FromJSON metadataPublic) => OryKratosBackend OryKratosClient traits metadataAdmin metadataPublic Source #

runOryKratosServer :: (MonadIO m, MonadThrow m, ToJSON traits, ToJSON adminMetadata, ToJSON publicMetadata) => Config -> OryKratosBackend (ExceptT ServerError IO) traits adminMetadata publicMetadata -> m () Source #

Run the OryKratos server at the provided host and port.

runOryKratosMiddlewareServer :: (MonadIO m, MonadThrow m, ToJSON traits, ToJSON adminMetadata, ToJSON publicMetadata) => Config -> Middleware -> OryKratosBackend (ExceptT ServerError IO) traits adminMetadata publicMetadata -> m () Source #

Run the OryKratos server at the provided host and port.

runOryKratosClient :: Config -> OryKratosClient a -> ExceptT ClientError IO a Source #

Run requests in the OryKratosClient monad.

runOryKratosClientWithManager :: Manager -> Config -> OryKratosClient a -> ExceptT ClientError IO a Source #

Run requests in the OryKratosClient monad using a custom manager.

callOryKratos :: (MonadIO m, MonadThrow m) => ClientEnv -> OryKratosClient a -> m a Source #

Like runClient, but returns the response or throws a OryKratosClientError

data OryKratosClient a Source #

Instances

Instances details
Monad OryKratosClient Source # 
Instance details

Defined in OryKratos.API

Functor OryKratosClient Source # 
Instance details

Defined in OryKratos.API

Methods

fmap :: (a -> b) -> OryKratosClient a -> OryKratosClient b #

(<$) :: a -> OryKratosClient b -> OryKratosClient a #

Applicative OryKratosClient Source # 
Instance details

Defined in OryKratos.API

MonadIO OryKratosClient Source # 
Instance details

Defined in OryKratos.API

Methods

liftIO :: IO a -> OryKratosClient a #

Servant

type OryKratosAPI traits metadataAdmin metadataPublic = ("version" :> Verb 'GET 200 '[JSON] GetVersion200Response) :<|> (("health" :> ("alive" :> Verb 'GET 200 '[JSON] IsAlive200Response)) :<|> (("health" :> ("ready" :> Verb 'GET 200 '[JSON] IsAlive200Response)) :<|> (("admin" :> ("identities" :> (ReqBody '[JSON] AdminCreateIdentityBody :> Verb 'POST 200 '[JSON] (Identity traits metadataAdmin metadataPublic)))) :<|> (("admin" :> ("recovery" :> ("link" :> (ReqBody '[JSON] AdminCreateSelfServiceRecoveryLinkBody :> Verb 'POST 200 '[JSON] SelfServiceRecoveryLink)))) :<|> (("admin" :> ("identities" :> (Capture "id" Text :> Verb 'DELETE 200 '[JSON] NoContent))) :<|> (("admin" :> ("identities" :> (Capture "id" Text :> ("sessions" :> Verb 'DELETE 200 '[JSON] NoContent)))) :<|> (("admin" :> ("sessions" :> (Capture "id" Text :> ("extend" :> Verb 'PATCH 200 '[JSON] (Session traits metadataAdmin metadataPublic))))) :<|> (("admin" :> ("identities" :> (Capture "id" Text :> (QueryParam "include_credential" (QueryList 'MultiParamArray Text) :> Verb 'GET 200 '[JSON] (Identity traits metadataAdmin metadataPublic))))) :<|> (("admin" :> ("identities" :> (QueryParam "per_page" Integer :> (QueryParam "page" Integer :> Verb 'GET 200 '[JSON] [Identity traits metadataAdmin metadataPublic])))) :<|> (("admin" :> ("identities" :> (Capture "id" Text :> ("sessions" :> (QueryParam "per_page" Integer :> (QueryParam "page" Integer :> (QueryParam "active" Bool :> Verb 'GET 200 '[JSON] [Session traits metadataAdmin metadataPublic]))))))) :<|> (("admin" :> ("identities" :> (Capture "id" Text :> (ReqBody '[JSON] AdminUpdateIdentityBody :> Verb 'PUT 200 '[JSON] (Identity traits metadataAdmin metadataPublic))))) :<|> (("self-service" :> ("logout" :> ("browser" :> (Header "cookie" Text :> Verb 'GET 200 '[JSON] SelfServiceLogoutUrl)))) :<|> (("schemas" :> (Capture "id" Text :> Verb 'GET 200 '[JSON] Value)) :<|> (("self-service" :> ("errors" :> (QueryParam "id" Text :> Verb 'GET 200 '[JSON] SelfServiceError))) :<|> (("self-service" :> ("login" :> ("flows" :> (QueryParam "id" Text :> (Header "Cookie" Text :> Verb 'GET 200 '[JSON] SelfServiceLoginFlow))))) :<|> (("self-service" :> ("recovery" :> ("flows" :> (QueryParam "id" Text :> (Header "Cookie" Text :> Verb 'GET 200 '[JSON] SelfServiceRecoveryFlow))))) :<|> (("self-service" :> ("registration" :> ("flows" :> (QueryParam "id" Text :> (Header "Cookie" Text :> Verb 'GET 200 '[JSON] SelfServiceRegistrationFlow))))) :<|> (("self-service" :> ("settings" :> ("flows" :> (QueryParam "id" Text :> (Header "X-Session-Token" Text :> (Header "Cookie" Text :> Verb 'GET 200 '[JSON] (SelfServiceSettingsFlow traits metadataAdmin metadataPublic))))))) :<|> (("self-service" :> ("verification" :> ("flows" :> (QueryParam "id" Text :> (Header "cookie" Text :> Verb 'GET 200 '[JSON] SelfServiceVerificationFlow))))) :<|> ((".well-known" :> ("ory" :> ("webauthn.js" :> Verb 'GET 200 '[JSON] Text))) :<|> (("self-service" :> ("login" :> ("browser" :> (QueryParam "refresh" Bool :> (QueryParam "aal" Text :> (QueryParam "return_to" Text :> Verb 'GET 200 '[JSON] SelfServiceLoginFlow)))))) :<|> (("self-service" :> ("login" :> ("api" :> (QueryParam "refresh" Bool :> (QueryParam "aal" Text :> (Header "X-Session-Token" Text :> Verb 'GET 200 '[JSON] SelfServiceLoginFlow)))))) :<|> (("self-service" :> ("recovery" :> ("browser" :> (QueryParam "return_to" Text :> Verb 'GET 200 '[JSON] SelfServiceRecoveryFlow)))) :<|> (("self-service" :> ("recovery" :> ("api" :> Verb 'GET 200 '[JSON] SelfServiceRecoveryFlow))) :<|> (("self-service" :> ("registration" :> ("browser" :> (QueryParam "return_to" Text :> Verb 'GET 200 '[JSON] SelfServiceRegistrationFlow)))) :<|> (("self-service" :> ("registration" :> ("api" :> Verb 'GET 200 '[JSON] SelfServiceRegistrationFlow))) :<|> (("self-service" :> ("settings" :> ("browser" :> (QueryParam "return_to" Text :> Verb 'GET 200 '[JSON] (SelfServiceSettingsFlow traits metadataAdmin metadataPublic))))) :<|> (("self-service" :> ("settings" :> ("api" :> (Header "X-Session-Token" Text :> Verb 'GET 200 '[JSON] (SelfServiceSettingsFlow traits metadataAdmin metadataPublic))))) :<|> (("self-service" :> ("verification" :> ("browser" :> (QueryParam "return_to" Text :> Verb 'GET 200 '[JSON] SelfServiceVerificationFlow)))) :<|> (("self-service" :> ("verification" :> ("api" :> Verb 'GET 200 '[JSON] SelfServiceVerificationFlow))) :<|> (("schemas" :> (QueryParam "per_page" Integer :> (QueryParam "page" Integer :> Verb 'GET 200 '[JSON] [IdentitySchema]))) :<|> (("sessions" :> (QueryParam "per_page" Integer :> (QueryParam "page" Integer :> (Header "X-Session-Token" Text :> (Header "Cookie" Text :> Verb 'GET 200 '[JSON] [Session traits metadataAdmin metadataPublic]))))) :<|> (("sessions" :> (Capture "id" Text :> Verb 'DELETE 200 '[JSON] NoContent)) :<|> (("sessions" :> (Header "X-Session-Token" Text :> (Header "Cookie" Text :> Verb 'DELETE 200 '[JSON] RevokedSessions))) :<|> (("self-service" :> ("login" :> (QueryParam "flow" Text :> (ReqBody '[JSON] SubmitSelfServiceLoginFlowBody :> (Header "X-Session-Token" Text :> (Header "Cookie" Text :> Verb 'POST 200 '[JSON] (SuccessfulSelfServiceLoginWithoutBrowser traits metadataAdmin metadataPublic))))))) :<|> (("self-service" :> ("logout" :> (QueryParam "token" Text :> (QueryParam "return_to" Text :> Verb 'GET 200 '[JSON] NoContent)))) :<|> (("self-service" :> ("logout" :> ("api" :> (ReqBody '[JSON] SubmitSelfServiceLogoutFlowWithoutBrowserBody :> Verb 'DELETE 200 '[JSON] NoContent)))) :<|> (("self-service" :> ("recovery" :> (QueryParam "flow" Text :> (QueryParam "token" Text :> (ReqBody '[JSON] SubmitSelfServiceRecoveryFlowBody :> (Header "Cookie" Text :> Verb 'POST 200 '[JSON] SelfServiceRecoveryFlow)))))) :<|> (("self-service" :> ("registration" :> (QueryParam "flow" Text :> (ReqBody '[JSON] SubmitSelfServiceRegistrationFlowBody :> (Header "Cookie" Text :> Verb 'POST 200 '[JSON] (SuccessfulSelfServiceRegistrationWithoutBrowser traits metadataAdmin metadataPublic)))))) :<|> (("self-service" :> ("settings" :> (QueryParam "flow" Text :> (ReqBody '[JSON] SubmitSelfServiceSettingsFlowBody :> (Header "X-Session-Token" Text :> (Header "Cookie" Text :> Verb 'POST 200 '[JSON] (SelfServiceSettingsFlow traits metadataAdmin metadataPublic))))))) :<|> (("self-service" :> ("verification" :> (QueryParam "flow" Text :> (QueryParam "token" Text :> (ReqBody '[JSON] SubmitSelfServiceVerificationFlowBody :> (Header "Cookie" Text :> Verb 'POST 200 '[JSON] SelfServiceVerificationFlow)))))) :<|> (("sessions" :> ("whoami" :> (Header "X-Session-Token" Text :> (Header "Cookie" Text :> Verb 'GET 200 '[JSON] (Session traits metadataAdmin metadataPublic))))) :<|> Raw)))))))))))))))))))))))))))))))))))))))))) Source #

Servant type-level API, generated from the OpenAPI spec for OryKratos.

Plain WAI Application

serverWaiApplicationOryKratos :: forall traits adminMetadata publicMetadata. (ToJSON traits, ToJSON adminMetadata, ToJSON publicMetadata) => OryKratosBackend (ExceptT ServerError IO) traits adminMetadata publicMetadata -> Application Source #

Plain Network.Wai Application for the OryKratos server.

Can be used to implement e.g. tests that call the API without a full webserver.