Commit Graph

34 Commits

Author SHA1 Message Date
hackerman 66edaddf59
chore: upgrade sdk generator (#4327) 2025-03-24 10:18:30 +01:00
Patrik 4fb28b3636
chore: align internal SDK with published SDK (#4019) 2024-07-31 17:08:51 +02:00
aeneasr 638b274313 feat: identifier first login for all first factor login methods 2024-07-11 16:08:34 +02:00
aeneasr 5d8e327603 chore: regenerate SDK 2024-07-11 16:08:34 +02:00
hackerman de6c8574c9
feat: support exporting of all credential types (#3290)
It's now possible to export all credential types (including passwords) when calling the `getIdentity` SDK method.
2023-05-24 18:20:14 +02:00
Arne Luenser 3bf6ec3d6d chore: one uuid library ought to be enough for everybody 2023-02-07 16:04:32 +01:00
aeneasr d77e2cf56c
fix: update year 2023-01-03 08:22:16 +01:00
Jonas Hungershausen a82ee92956
feat: add verification via `code` (#2838)
The new `code` strategy is now supported as a verification strategy. If enabled, the strategy sends a code, instead of a magic link to the user's address, which they can use to verify their address.

Close #2824
2022-11-15 11:18:58 +01:00
aeneasr 11f9d30a5d refactor: SDK v1 naming
Find the full [upgrade guide in our documentation](https://www.ory.sh/docs/guides/upgrade/sdk).
2022-11-11 15:00:23 +01:00
aeneasr e9aa21f02b refactor: make embedding easier with internal sdk 2022-11-11 15:00:23 +01:00
Kevin Goslar 8406eaf920
feat: standardize license headers (#2790) 2022-11-08 17:41:34 +01:00
Jonas Hungershausen a1532ba797
feat: replace magic links with one time codes in recovery flow (#2645)
This feature introduces a new `code` strategy to recover an account. 

Currently, if a user needs to initiate a recovery flow to recover a lost password/MFA/etc., they’ll receive an email containing a “magic link”. This link contains a flow_id and a recovery_token. This is problematic because some antivirus software opens links in emails to check for malicious content, etc.

Instead of the magic link, we send an 8-digit code that is clearly displayed in the email or SMS. A user can now copy/paste or type it manually into the text-field that is shown after the user clicks “submit” on the initiate flow page.

Closes #1451

BREAKING CHANGES: This patch changes the behavior of the recovery flow. It introduces a new strategy for account recovery that sends out short "one-time passwords" (`code`) that a user can use to prove ownership of their account and recovery access to it. This PR also updates the default recovery strategy to `code`.
2022-10-06 14:28:54 +02:00
aeneasr fc9573070a chore: go 1.19 format 2022-09-02 11:48:01 +02:00
aeneasr 24eddfb2ad Revert "autogen(openapi): regenerate swagger spec and internal client"
This reverts commit 4159b93ae3.
2022-08-19 17:10:15 +02:00
ory-bot 4159b93ae3 autogen(openapi): regenerate swagger spec and internal client
[skip ci]
2022-08-15 15:21:22 +00:00
Mitsuo Heijo 61f12e7579
fix: use pointer of string for PasswordIdentifier in example code (#2421) 2022-04-24 22:21:44 +02:00
hackerman 686c9ba08f
refactor: rename `whitelisted_return_urls` to `allowed_return_urls` (#2299)
BREAKING CHANGE: Configuration key `selfservice.whitelisted_return_urls` has been renamed to `allowed_return_urls`.
2022-03-11 10:04:22 +01:00
aeneasr d44af289e9 test: resolve potential panic 2022-02-14 19:47:51 +01:00
hackerman e4f205d69b refactor: identity.default_schema_url is now `identity.default_schema_id` (#1964)
BREAKING CHANGES: A major issue has been lingering in the configuration for a while. What happens to your identities when you update a schema? The answer was, it depends on the change. If the change is incompatible, some things might break!

To resolve this problem we changed the way you define schemas. Instead of having a global `default_schema_url` which developers used to update their schema, you now need to define the `default_schema_id` which must reference schema ID in your config. To update your existing configuration, check out the patch example below:

```patch
identity:
-  default_schema_url: file://stub/identity.schema.json
+  default_schema_id: default
+  schemas:
+  - id: default
+    url: file://stub/identity.schema.json
```

Ideally, you would version your schema and update the `default_schema_id` with every change to the new version:

```yaml
identity:
  default_schema_id: user_v1
  schemas:
    - id: user_v0
      url: file://path/to/user_v0.json
    - id: user_v1
      url: file://path/to/user_v1.json
```
2022-02-14 19:47:51 +01:00
aeneasr 3f067386e3 refactor: sdk API is no v0alpha2
BREAKING CHANGE: The SDKs are now generated with tag v0alpha2 to reflect that some signatures have changed in a breaking fashion. Please update your imports from `v0alpha1` to `v0alpha2`.
2021-10-19 08:48:27 +02:00
hackerman 198991a9ce
feat: API to return access, refresh, id tokens from social sign in (#1818)
This patch introduces the new `include_credential` query parameter to the `GET /identities` endpoint which allows administrators to receive the initial access, refresh, and ID tokens from Social Sign In (OpenID Connect / OAuth 2.0) flows.

These tokens can be stored in an encrypted format (XChaCha20Poly1305 or AES-GCM) in the database if an appropriate encryption secret is set. To get started easily these values are not encrypted per default.

For more information head [over to the docs](https://kratos/docs/guides/retrieve-social-sign-in-access-refresh-id-token).

Closes #1518
Closes #397
2021-10-12 12:04:29 +02:00
seremenko-wish 7f44f819a5
feat: TLS support for public and admin endpoints (#1466)
Implements #791

Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com>
2021-07-12 13:56:34 +02:00
aeneasr e772641f9b refactor: finalize SDK refactoring
BREAKING CHANGE: This change introduces a better SDK. As part of this change, several breaking changes with regards to the SDK have been introduced. We recommend reading this section carefully to understand the changes and how they might affect you.

Before, the SDK was structured into tags `public` and `admin`. This stems from the fact that we have two ports in Ory Kratos - one administrative and one public port.

While serves as a good overview when working with Ory Kratos, it does not express:

- What module the API belongs to (e.g. self-service, identity, ...)
- What maturity the API has (e.g. experimental, alpha, beta, ...)
- What version the API has (e.g. v0alpha0, v1beta0, ...)

This patch replaces the current `admin` and `public` tags with a versioned approach indicating the maturity of the API used. For example, `initializeSelfServiceSettingsForBrowsers` would no longer be under the `public` tag but instead under the `v0alpha1` tag:

```patch
import {
  Configuration,
- PublicApi
+ V0Alpha1
} from '@ory/kratos-client';

- const kratos = new PublicApi(new Configuration({ basePath: config.kratos.public }));
+ const kratos = new V0Alpha1(new Configuration({ basePath: config.kratos.public }));
```

To avoid confusion when setting up the SDK, and potentially using the wrong endpoints in your codebase and ending up with strange 404 errors, Ory Kratos now redirects you to the correct port, given that `serve.(public|admin).base_url` are configured correctly. This is a significant improvement towards a more robust API experience!

Further, all administrative functions require, in the Ory SaaS, authorization using e.g. an Ory Personal Access Token. In the open source, we do not know what developers use to protect their APIs. As such, we believe that it is ok to have admin and public functions under one common API and differentiate with an `admin` prefix. Therefore, the following patches should be made in your codebase:

```patch
import {
- AdminApi,
+ V0Alpha1,
  Configuration
} from '@ory/kratos-client';

-const kratos = new AdminApi(new Configuration({ basePath: config.kratos.admin }));
+const kratos = new V0Alpha1(new Configuration({ basePath: config.kratos.admin }));

-kratos.createIdentity({
+kratos.adminCreateIdentity({
  schema_id: 'default',
  traits: { /* ... */ }
})
```

Further, we have introduced a [style guide for writing SDKs annotations](https://www.ory.sh/docs/ecosystem/contributing#openapi-spec-and-go-swagger) governing how naming conventions should be chosen.

We also streamlined how credentials are used. We now differentiate between:

- Per-request credentials such as the Ory Session Token / Cookie
    ```
    - public getSelfServiceRegistrationFlow(id: string, cookie?: string, options?: any) {}
    + public getSelfServiceSettingsFlow(id: string, xSessionToken?: string, cookie?: string, options?: any) {}
    ```
- Global credentials such as the Ory (SaaS) Personal Access Token.
    ```typescript
    const kratos = new V0Alpha0(new Configuration({ basePath: config.kratos.admin, accessToken: 'some-token' }));

    kratosAdmin.adminCreateIdentity({
      schema_id: 'default',
      traits: { /* ... */ },
    });
    ```

We hope you enjoy the vastly improved experience! There are still many things that we want to iterate on. For full context, we recommend reading the proposal and discussion around these changes at [kratos#1424](https://github.com/ory/kratos/issues/1424).

Additionally, the Self-Service Error endpoint was updated. First, the endpoint `/self-service/errors` is now located at the public port only with the admin port redirecting to it. Second, the parameter `?error` was renamed to `?id` for better SDK compatibility. Parameter `?error` is still working but will be deprecated at some point. Third, the response no longer contains an error array in `errors` but instead just a single error under `error`:

```patch
{
  "id": "60208346-3a61-4880-96ae-0419cde8fca8",
- "errors": [{
+ "error": {
    "code": 404,
    "status": "Not Found",
    "reason": "foobar",
    "message": "The requested resource could not be found"
- }],
+ },
  "created_at": "2021-07-07T11:20:15.310506+02:00",
  "updated_at": "2021-07-07T11:20:15.310506+02:00"
}
```

Closes #1424
2021-07-11 13:15:25 +02:00
aeneasr 65c482fba6 refactor: self-service error APIs 2021-07-11 13:15:25 +02:00
aeneasr 870c2bd316 feat: add examples for usage of go sdk 2021-07-11 13:15:25 +02:00
aeneasr 844e164c9c chore: regenerate sdks and rename v0alpha0 -> v1alpha1 2021-07-11 13:15:25 +02:00
aeneasr d8658dc887 refactor: identity SDKs
See #1477
2021-07-11 13:15:25 +02:00
hackerman b9c7674c30
feat: add helper for starting kratos e2e (#1469) 2021-06-30 11:04:10 +02:00
hackerman 51715572ea
feat: anti-CSRF measures when fetching flows (#1458)
BREAKING CHANGE: This patch introduces CSRF countermeasures for fetching all self-service flows. This ensures that users can not accidentally leak sensitive information when copy/pasting e.g. login URLs (see #1282). If a self-service flow for browsers is requested, the CSRF cookie must be included in the call, regardless if it is a client-side browser app or a server-side browser app calling. This **does not apply** for API-based flows.

As part of this change, the following endpoints have been removed:

- `GET <ory-kratos-admin>/self-service/login/flows`;
- `GET <ory-kratos-admin>/self-service/registration/flows`;
- `GET <ory-kratos-admin>/self-service/verification/flows`;
- `GET <ory-kratos-admin>/self-service/recovery/flows`;
- `GET <ory-kratos-admin>/self-service/settings/flows`.

Please ensure that your server-side applications use the public port (e.g. `GET <ory-kratos-public>/self-service/login/flows`) for fetching self-service flows going forward.

If you use the SDKs, upgrading is easy by adding the `cookie` header when fetching the flows. This is only required when **using browser flows on the server side**.

The following example illustrates a ExpressJS (NodeJS) server-side application fetching the self-service flows.

```patch
app.get('some-route', (req: Request, res: Response) => {
-   kratos.getSelfServiceLoginFlow(flow).then((flow) => /* ... */ )
+   kratos.getSelfServiceLoginFlow(flow, req.header('cookie')).then((flow) => /* ... */ )

-   kratos.getSelfServiceRecoveryFlow(flow).then((flow) => /* ... */ )
+   kratos.getSelfServiceRecoveryFlow(flow, req.header('cookie')).then((flow) => /* ... */ )

-   kratos.getSelfServiceRegistrationFlow(flow).then((flow) => /* ... */ )
+   kratos.getSelfServiceRegistrationFlow(flow, req.header('cookie')).then((flow) => /* ... */ )

-   kratos.getSelfServiceVerificationFlow(flow).then((flow) => /* ... */ )
+   kratos.getSelfServiceVerificationFlow(flow, req.header('cookie')).then((flow) => /* ... */ )

-   kratos.getSelfServiceSettingsFlow(flow).then((flow) => /* ... */ )
+   kratos.getSelfServiceSettingsFlow(flow, undefined, req.header('cookie')).then((flow) => /* ... */ )
})
```

For concrete details, check out [the changes in the NodeJS app](e7fa292968).

Closes #1282
2021-06-30 10:11:23 +02:00
hackerman 1a7a74c3fe
feat: protect logout against CSRF (#1433)
BREAKING CHANGE: This patch refactors the logout functionality for browsers and APIs. It adds increased security and DoS-defenses to the logout flow.

Previously, calling `GET /self-service/browser/flows/logout` would remove the session cookie and redirect the user to the logout endpoint. Now you have to make a call to `GET /self-service/logout/browser` which returns a JSON response including a `logout_url` URL to be used for logout. The call to `/self-service/logout/browser` must be made using AJAX with cookies enabled or by including the Ory Session Cookie in the `X-Session-Cookie` HTTP Header. You may also use the SDK method `createSelfServiceLogoutUrlForBrowsers` to do that.

Additionally, the endpoint `DELETE /sessions` has been moved to `DELETE /self-service/logout/api`. Payloads and responses stay equal. The SDK method `revokeSession` has been renamed to `submitSelfServiceLogoutFlowWithoutBrowser`.

Closes #142
2021-06-20 15:36:05 +02:00
hackerman ecb0a01f61
fix: incorrect openapi specification for verification submission (#1431)
Closes #1368
2021-06-16 16:11:27 +02:00
aeneasr 3b56bb5fd3 docs: add tested and running go sdk examples 2021-06-16 08:31:46 +02:00
aeneasr 8ab8607dee docs: add replit instructions 2021-06-16 08:31:46 +02:00
aeneasr e948faddce docs: add go sdk examples 2021-06-16 08:31:46 +02:00