Coder Social home page Coder Social logo

dystudio / kratos-selfservice-ui-node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ory/kratos-selfservice-ui-node

0.0 1.0 0.0 558 KB

License: Apache License 2.0

TypeScript 45.69% HTML 37.46% CSS 13.15% Dockerfile 0.75% Shell 0.83% Makefile 2.12%

kratos-selfservice-ui-node's Introduction

kratos-selfservice-ui-node

CircleCI

This is an exemplary Self Service UI for ORY Kratos Self Service features:

  • Registration
  • Login
  • Logout
  • User settings
    • Update profile
    • Change password
  • Password reset
  • ORY Kratos user error page

Additionally:

  • Dashboard (requires login)

Configuration

This application can be configured using two environment variables:

  • KRATOS_ADMIN_URL (required): The URL where ORY Kratos's Admin API is located at. If this app and ORY Kratos are running in the same private network, this should be the private network address (e.g. kratos-admin.svc.cluster.local).
  • KRATOS_PUBLIC_URL (required): The URL where ORY Kratos's Public API is located at. If this app and ORY Kratos are running in the same private network, this should be the private network address (e.g. kratos-public.svc.cluster.local).
  • BASE_URL (optional): The base url of this app. If served e.g. behind a proxy or via GitHub pages this would be the path, e.g. https://mywebsite.com/kratos-selfservice-ui-node/. Must be absolute!
  • TLS_CERT_PATH (optional): Path to certificate file. Should be set up together with TLS_KEY_PATH to enable HTTPS.
  • TLS_KEY_PATH (optional): Path to key file Should be set up together with TLS_CERT_PATH to enable HTTPS.

Network Setup

This application works in two set ups:

  • Standalone with ORY Kratos
  • With the ORY Oathkeeper Reverse Proxy

Standalone using cookies

This mode adds a route to the app which proxies all traffic flowing to /.ory/kratos/public/* to ORY Kratos' Public API. That way, this app and ORY Kratos share the same domain and port which makes cookies work.

To authenticate incoming requests, this app uses ORY Kratos' whoami API to check whether the session is valid or not.

To enable this mode, set the environment variable SECURITY_MODE=cookie.

With Oathkeeper using JSON Web Tokens (JWT)

This mode requires ORY Oathkeeper to route all incoming traffic to either ORY Kratos or this app. It is expected that no browser traffic can reach this app or ORY Kratos directly.

This app then expects ORY Oathkeeper to use the id_token mutator which is a JSON Web Token this app validates in order to figure out if a request is authorized (logged in) or not.

To enable this mode, set the environment variable SECURITY_MODE=jwt. Additionally these two environment variables must be set:

  • JWKS_URL: This URL contains the JSON Web Key Sets ("jwks") that can be used to verify the JSON Web Tokens. When using ORY Oathkeeper, you should point this URL to ORY Oathkeeper's JWKS API (the API port, not the proxy port!), e.g. https://my-oathkeeper-api/.well-known/jwks.json.
  • KRATOS_BROWSER_URL: The URL where ORY Kratos's public API is located, when accessible from the public internet via ORY Oathkeeper. This could be for example http://kratos.my-app.com/.

Development

To run this app with dummy data and no real connection to ORY Kratos, use:

$ NODE_ENV=stub npm start

Test with ORY Kratos

The easiest way to test this app with a local installation of ORY Kratos is to use SECURITY_MODE=cookie and have the ORY Kratos Quickstart running. This is what that would look like:

# start the quickstart using docker compose as explained in the tutorial: https://www.ory.sh/kratos/docs/quickstart/
export SECURITY_MODE=cookie
export KRATOS_PUBLIC_URL=http://127.0.0.1:4433/
export KRATOS_ADMIN_URL=http://127.0.0.1:4434/
export PORT=4455

# In ORY Kratos run the quickstart:
#
#   make quickstart-dev
# 
# Next you need to kill the docker container that runs this app in order to free the ports:
#
#   docker kill kratos_oathkeeper_1

npm start

Update TypeScript SDK

If you've made changes to the ORY Kratos API you may want to manually generate the TypeScript SDK in order for URLs and payloads to work as expected. It is expected that you start this guide from this project's root, wherever you checked it out. You also need to have the openapi-generator installed.

# Set path to kratos:
export KRATOS_DIR=/path/to/kratos
make build-sdk

Building the Docker Image

# Set path to kratos:
export KRATOS_DIR=/path/to/kratos
make build-sdk-docker

Clean up

make clean-sdk

kratos-selfservice-ui-node's People

Contributors

aeneasr avatar anuveyatsu avatar christian-roggia avatar dependabot[bot] avatar guillett avatar jfcurran avatar programmador avatar vkiller avatar zepatrik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.