{"id":19806350,"url":"https://github.com/ory/kratos-selfservice-ui-node","last_synced_at":"2025-05-14T18:03:04.931Z","repository":{"id":38205250,"uuid":"216524708","full_name":"ory/kratos-selfservice-ui-node","owner":"ory","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-07T12:25:10.000Z","size":2393,"stargazers_count":336,"open_issues_count":15,"forks_count":217,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-07T13:32:43.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"patreon":"_ory","open_collective":"ory"}},"created_at":"2019-10-21T09:08:07.000Z","updated_at":"2025-05-07T12:25:14.000Z","dependencies_parsed_at":"2023-12-20T16:04:52.222Z","dependency_job_id":"9ee6c667-f1ea-48fa-9911-2dea3b411aa0","html_url":"https://github.com/ory/kratos-selfservice-ui-node","commit_stats":{"total_commits":457,"total_committers":44,"mean_commits":"10.386363636363637","dds":"0.42450765864332607","last_synced_commit":"3b54227d08d417c394170cf781fe82ee7fff53b6"},"previous_names":[],"tags_count":144,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ory%2Fkratos-selfservice-ui-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ory%2Fkratos-selfservice-ui-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ory%2Fkratos-selfservice-ui-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ory%2Fkratos-selfservice-ui-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ory","download_url":"https://codeload.github.com/ory/kratos-selfservice-ui-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253832254,"owners_count":21971235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T09:07:20.052Z","updated_at":"2025-05-14T18:03:04.880Z","avatar_url":"https://github.com/ory.png","language":"TypeScript","funding_links":["https://patreon.com/_ory","https://opencollective.com/ory"],"categories":[],"sub_categories":[],"readme":"# Ory Kratos NodeJS / ExpressJS User Interface Reference Implementation\n\n[![tests](https://github.com/ory/kratos-selfservice-ui-node/actions/workflows/test.yml/badge.svg)](https://github.com/ory/kratos-selfservice-ui-node/actions/workflows/test.yml)\n\nThis repository contains a reference implementation for Ory Kratos' in NodeJS /\nExpressJS / Handlebars / NextJS. It implements all Ory Kratos flows (login,\nregistration, account settings, account recovery, account verification).\n\nIf you only want to add authentication to your app, and not customize the login,\nregistration, account recovery, ... screens, please check out the\n[Ory Kratos Quickstart](https://www.ory.sh/kratos/docs/quickstart).\n\n## Configuration\n\nBelow is a list of environment variables required by the Express.js service to\nfunction properly.\n\nIn a local development run of the service using `npm run start`, some of these\nvalues will be set by nodemon and is configured by the `nodemon.json` file.\n\nWhen using this UI with an Ory Network project, you can use `ORY_SDK_URL`\ninstead of `KRATOS_PUBLIC_URL` and `HYDRA_ADMIN_URL`.\n\nOry Identities requires the following variables to be set:\n\n- `ORY_SDK_URL` or `KRATOS_PUBLIC_URL` (required): The URL where ORY Kratos's\n  Public API is located at. If this app and ORY Kratos are running in the same\n  private network, this should be the private network address (e.g.\n  `kratos-public.svc.cluster.local`).\n- `KRATOS_BROWSER_URL` (optional) The browser accessible URL where ORY Kratos's\n  public API is located, only needed if it differs from `KRATOS_PUBLIC_URL`\n- `KRATOS_ADMIN_URL` (optional) The URL where Ory Kratos' Admin API is located\n  at (e.g. `http://kratos:4434`).\n\nOry OAuth2 requires more setup to get CSRF cookies on the `/consent` endpoint.\n\n- `ORY_SDK_URL` or `HYDRA_ADMIN_URL` (optional): The URL where Ory Hydra's Admin\n  API is located at. If this app and Ory Hydra are running in the same private\n  network, this should be the private network address (e.g.\n  `hydra-admin.svc.cluster.local`)\n- `COOKIE_SECRET` (required): Required for signing cookies. Must be a string\n  with at least 8 alphanumerical characters.\n- `CSRF_COOKIE_NAME` (required): Change the cookie name to match your domain\n  using the `__HOST-example.com-x-csrf-token` format.\n- `CSRF_COOKIE_SECRET` (optional): Required for the Consent route to set a CSRF\n  cookie with a hashed value. The value must be a string with at least 8\n  alphanumerical characters.\n- `REMEMBER_CONSENT_SESSION_FOR_SECONDS` (optional): Sets the `remember_for`\n  value of the accept consent request in seconds. The default is 3600 seconds.\n- `ORY_ADMIN_API_TOKEN` (optional): When using with an Ory Network project, you\n  should add the `ORY_ADMIN_API_TOKEN` for OAuth2 Consent flows.\n- `DANGEROUSLY_DISABLE_SECURE_CSRF_COOKIES` (optional) This environment\n  variables should only be used in local development when you do not have HTTPS\n  setup. This sets the CSRF cookies to `secure: false`, required for running\n  locally. When using this setting, you must also set `CSRF_COOKIE_NAME` to a\n  name without the `__Host-` prefix.\n- `TRUSTED_CLIENT_IDS` (optional): A list of trusted client ids. They can be set\n  to skip the consent screen.\n\nGetting TLS working:\n\n- `TLS_CERT_PATH` (optional): Path to certificate file. Should be set up\n  together with `TLS_KEY_PATH` to enable HTTPS.\n- `TLS_KEY_PATH` (optional): Path to key file Should be set up together with\n  `TLS_CERT_PATH` to enable HTTPS.\n\nThis is the easiest mode as it requires no additional set up. This app runs on\nport `:4455` and ORY Kratos `KRATOS_PUBLIC_URL` URL.\n\nThis mode relies on the browser's ability to send cookies regardless of the\nport. Cookies set for `127.0.0.1:4433` will thus also be sent when requesting\n`127.0.0.1:4455`. For environments where applications run on separate\nsubdomains, check out\n[Multi-Domain Cookies](https://www.ory.sh/kratos/docs/guides/multi-domain-cookies)\n\nTo authenticate incoming requests, this app uses ORY Kratos' `whoami` API to\ncheck whether the session is valid or not.\n\n### Base Path\n\nThere are two ways of serving this application under a base path:\n\n1. Let Express.js handle the routing by setting the `BASE_PATH` environment\n   variable to the sub-path, e.g. `/myapp`.\n2. Use a reverse proxy or API gateway to strip the path prefix.\n\nThe second approach is not always possible, especially when running the\napplication on a serverless environment. In this case, the first approach is\nrecommended.\n\n## Development\n\nTo run this app with dummy data and no real connection to ORY Kratos, use:\n\n```shell script\nNODE_ENV=stub npm start\n```\n\nIf you would like to also generate fake data for the `id_token`, please set the\nenvironment varialbe `export CONFORMITY_FAKE_CLAIMS=1`\n\n### Test with ORY Kratos\n\nThe easiest way to test this app with a local installation of ORY Kratos is to\nhave the [ORY Kratos Quickstart](https://www.ory.sh/kratos/docs/quickstart/)\nrunning. This is what that would look like:\n\n```shell script\n# start the quickstart using docker compose as explained in the tutorial: https://www.ory.sh/kratos/docs/quickstart/\nexport KRATOS_PUBLIC_URL=http://127.0.0.1:4433/\nexport PORT=4455\n\n# In ORY Kratos run the quickstart:\n#\n#   make quickstart-dev\n#\n# Next you need to kill the docker container that runs this app in order to free the ports:\n#\n#   docker kill kratos_kratos-selfservice-ui-node_1\n\nnpm start\n```\n\n### Update TypeScript SDK\n\nIf you've made changes to the ORY Kratos API you may want to manually generate\nthe TypeScript SDK in order for URLs and payloads to work as expected. It is\nexpected that you start this guide from this project's root, wherever you\nchecked it out. You also need to have the\n[`openapi-generator` installed](https://openapi-generator.tech/docs/installation).\n\n```shell script\n# Set path to kratos:\nexport KRATOS_DIR=/path/to/kratos\nmake build-sdk\n```\n\n#### Building the Docker Image\n\n```shell script\n# Set path to kratos:\nexport KRATOS_DIR=/path/to/kratos\nmake build-sdk-docker\n```\n\n#### Clean up\n\n```shell script\nmake clean-sdk\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fory%2Fkratos-selfservice-ui-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fory%2Fkratos-selfservice-ui-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fory%2Fkratos-selfservice-ui-node/lists"}