Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: securing the Admin UI #2588

Merged
merged 39 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cc9e964
feat: basic infrastructure
JoblersTune Mar 20, 2024
d28f452
feat: basic implementation of flows
JoblersTune Mar 20, 2024
51efee9
chore: add Kratos session checks for route files
JoblersTune Mar 20, 2024
9cb6533
fix: updated correct baseUrl for Kratos methods config
JoblersTune Mar 20, 2024
fe22ad1
chore: added types required for qs module
JoblersTune Mar 20, 2024
8caa713
chore: removed Hydra components
JoblersTune Mar 22, 2024
c5f7ff3
chore: changed Second Kratos port and some clean up
JoblersTune Mar 22, 2024
7f8eff4
fix: kratos links redirect to the same tab and user input values can …
JoblersTune Mar 22, 2024
fda52d7
fix: userInvitation script can resend recovery links if the user exis…
JoblersTune Mar 22, 2024
04cd3c6
fix: frontend styling
JoblersTune Mar 22, 2024
2c345b2
feat: added doc updates
JoblersTune Mar 22, 2024
8307887
Merge branch 'main' of github.com:interledger/rafiki into sj/2200-adm…
JoblersTune Apr 8, 2024
9a53fa4
chore: implementing PR feedback and fixing merge conflicts with main
JoblersTune Apr 8, 2024
35664f7
fix: added skipLibCheck to ignore node_module type errors
JoblersTune Apr 8, 2024
7f2e2e3
chore: improving dev experience by running the admin UI in dev mode i…
JoblersTune Apr 9, 2024
4152ae0
chore: handling the case of a missing logoutUrl with a manual logout …
JoblersTune Apr 9, 2024
7b0269f
chore: formatting
JoblersTune Apr 9, 2024
5a37dd1
chore: wording fixes and building kratos scripts when running remix dev
JoblersTune Apr 9, 2024
bc95e13
fix: bind mount is now read only with the frontend/app folder to avoi…
JoblersTune Apr 12, 2024
f1a25c4
feat: introduce Pino for Admin UI serverside logging
JoblersTune Apr 12, 2024
8dcd1fe
chore: made new Dockerfile a devDockerfile, keeping the current Docke…
JoblersTune Apr 12, 2024
a1411c2
Apply suggestions from code review
JoblersTune Apr 12, 2024
d5633c0
chore: using localhost instead of 127.0.01
JoblersTune Apr 12, 2024
2856f4c
fix: removed redundant pnpm install command
JoblersTune Apr 12, 2024
85a7377
chore: removed redundant line
JoblersTune Apr 12, 2024
5579594
chore: using template literals in logging string
JoblersTune Apr 12, 2024
7255e59
chore: updating docs and READMEs
JoblersTune Apr 15, 2024
4df798f
Merge branch 'main' of github.com:interledger/rafiki into sj/2200-adm…
JoblersTune Apr 16, 2024
e2ab514
chore: resolved mnerge conflicts
JoblersTune Apr 16, 2024
3c27922
fix: removed unnecessary Kratos identity schema ID
JoblersTune Apr 16, 2024
752a6f6
chore: moving remix dev command back to Dockerfile instead of in dock…
JoblersTune Apr 16, 2024
c1b89bd
documentation: updated docs and architecture image
JoblersTune Apr 16, 2024
43cb41a
fix: removed extra spcaes
JoblersTune Apr 16, 2024
d9ea02b
chore: included original excalidraw file for localenv-architecture
JoblersTune Apr 17, 2024
c2f56ef
chore: updated localenv-architecture excalidraw image
JoblersTune Apr 17, 2024
e17c1ce
chore: frontend README tweaks
JoblersTune Apr 17, 2024
8cf8214
chore: remove ESNext and ESNext.Promise from tsconfig
JoblersTune Apr 17, 2024
2e9f724
fix: frontend README wording fix
JoblersTune Apr 17, 2024
2682599
fix: removed unused DSN env var from kratos docker-compose setup
JoblersTune Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 26 additions & 8 deletions localenv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ These packages include:
- `auth` (GNAP auth server)
JoblersTune marked this conversation as resolved.
Show resolved Hide resolved
- `mock-account-servicing-entity` (mocks an [Account Servicing Entity](https://rafiki.dev/concepts/account-servicing-entity/)
- `frontend` (Remix app to expose a UI for Rafiki Admin management via interaction with the `backend` Admin APIs)
- `kratos` (An identity and user management solution for the `frontend`)
- `mailslurper` (A SMTP mail server to catch account recovery emails)

These packages depend on the following databases:

Expand All @@ -31,26 +33,34 @@ This environment will set up a playground where you can use the Rafiki Admin API

(c) Open Payments API - accessible at http://localhost:3000

(d) Admin UI - accessible at http://localhost:3010
(d) Auth Admin API - accessible at http://localhost:3003/graphql

(e) Auth Admin API - accessible at http://localhost:3003/graphql
(e) Open Payments Auth API - accessible at http://localhost:3006

(f) Open Payments Auth API - accessible at http://localhost:3006
(f) Admin UI - accessible at http://localhost:3010

#### Happy Life Bank
(g) Kratos API - accessible at http://localhost:4433

(g) User Interface - accessible at http://localhost:3031
#### Happy Life Bank

(h) Admin API - accessible at http://localhost:4001/graphql
(h) User Interface - accessible at http://localhost:3031

(i) Open Payments API - accessible at http://localhost:4000
(i) Admin API - accessible at http://localhost:4001/graphql

(j) Admin UI - accessible at http://localhost:4010
(j) Open Payments API - accessible at http://localhost:4000

(k) Auth Admin API - accessible at http://localhost:4003/graphql

(l) Open Payments Auth API - accessible at http://localhost:4006

(m) Admin UI - accessible at http://localhost:4010

(n) Kratos API - accessible at http://localhost:4432

#### Mail Slurper

(o) Mail UI - accessible at http://localhost:4436

#### Database

Postgres Server - accessible at http://localhost:5432
Expand Down Expand Up @@ -186,6 +196,14 @@ Note that you have to go through an interaction flow by clicking on the `redirec

In order to manage, and view information about the Rafiki instance(s) using a UI, you can navigate to [`localhost:3010`](http://localhost:3010) (Cloud Nine Wallet) or [`localhost:4010`](http://localhost:4010) (Happy Life Bank). This is the `frontend` project which runs a Remix app for querying info and executing mutations against the Rafiki [Admin APIs](#admin-apis).

We have secured access to the Admin UI using [Ory Kratos](https://www.ory.sh/docs/kratos/ory-kratos-intro), a secure and fully open-source identity and user management solution. Check it out on [GitHub](https://github.com/ory/kratos). Since access to the UI is on an invitation-only basis the registration flow is not publicly available. As such, in order to access the Admin UI you can click the registration link provided in the logs during `localenv` startup or you can manually add a new user with the invite-user script. Run `docker exec -it <admin-container-name> npm run invite-user -- example@mail.com` and it will output recovery link to the terminal. The recovery link doubles as the invitation method. Copy and paste this link in your browser and you will automatically be logged in and directed to the account settings page. The next step is changing your password. We're using a simple email and password authentication method.

There is a password recovery flow. On the login page if you clkick the `forgot password` link and enter an email for a registered user then you can open [Mail Slurper](http://localhost:4436) to access the recovery link for your account.

We've also included a script to remove users: `docker exec -it <admin-container-name> npm run delete-user -- example@mail.com`.

See the `frontend` [README](../packages/frontend/README.md) for more information.

#### Admin APIs

In addition to the using the Admin UI for interacting with the Admin APIs, you can also use the Apollo explorer (on [`localhost:3001/graphql`](http://localhost:3001/graphql) and [`localhost:4001/graphql`](http://localhost:4001/graphql), respectively), and also via the [Bruno collection](https://github.com/interledger/rafiki/tree/main/bruno/collections/Rafiki/Rafiki%20Admin%20APIs). The Bruno collection is configured to use the default endpoints of the local environment.
Expand Down
8 changes: 8 additions & 0 deletions localenv/cloud-nine-wallet/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ ALTER DATABASE happy_life_bank_backend OWNER TO happy_life_bank_backend;
CREATE USER happy_life_bank_auth WITH PASSWORD 'happy_life_bank_auth';
CREATE DATABASE happy_life_bank_auth;
ALTER DATABASE happy_life_bank_auth OWNER TO happy_life_bank_auth;

CREATE USER happy_life_kratos WITH PASSWORD 'kratos_password';
CREATE DATABASE happy_life_kratos;
ALTER DATABASE happy_life_kratos OWNER TO happy_life_kratos;

CREATE USER cloud_nine_kratos WITH PASSWORD 'kratos_password';
CREATE DATABASE cloud_nine_kratos;
ALTER DATABASE cloud_nine_kratos OWNER TO cloud_nine_kratos;
36 changes: 34 additions & 2 deletions localenv/cloud-nine-wallet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,52 @@ services:
image: rafiki-frontend
build:
context: ../..
dockerfile: ./packages/frontend/Dockerfile
dockerfile: ./packages/frontend/devDockerfile
volumes:
- type: bind
source: ../../packages/frontend/app
target: /home/rafiki/packages/frontend/app
read_only: true
restart: always
networks:
- rafiki
ports:
- '3010:3010'
environment:
PORT: 3010
LOG_LEVEL: debug
NODE_ENV: ${NODE_ENV:-development}
GRAPHQL_URL: http://cloud-nine-wallet-backend:3001/graphql
OPEN_PAYMENTS_URL: https://cloud-nine-wallet-backend/
ENABLE_INSECURE_MESSAGE_COOKIE: true
KRATOS_CONTAINER_PULIC_URL: 'http://cloud-nine-kratos:4433'
KRATOS_BROWSER_PUBLIC_URL: 'http://localhost:4433'
KRATOS_ADMIN_URL: 'http://cloud-nine-kratos:4434/admin'
depends_on:
- cloud-nine-backend

- cloud-nine-kratos
cloud-nine-kratos:
build:
context: ../..
dockerfile: ./packages/frontend/kratos/Dockerfile
args:
PATH_TO_KRATOS_CONFIG: ./localenv/cloud-nine-wallet/kratos.yml
depends_on:
- shared-database
- mailslurper
environment:
DEV_MODE: true
ports:
- "4433:4433"
networks:
- rafiki
mailslurper:
image: oryd/mailslurper:latest-smtps
ports:
- "4436:4436"
- "4437:4437"
networks:
- rafiki

volumes:
database-data: # named volumes can be managed easier using docker-compose
91 changes: 91 additions & 0 deletions localenv/cloud-nine-wallet/kratos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
version: v0.13.0

dsn: postgres://cloud_nine_kratos:kratos_password@shared-database:5432/cloud_nine_kratos?sslmode=disable&max_conns=20&max_idle_conns=4

serve:
public:
base_url: http://localhost:4433/
cors:
enabled: true
admin:
base_url: http://cloud-nine-kratos:4434/

selfservice:
default_browser_return_url: http://localhost:3010/
allowed_return_urls:
- http://localhost:3010

methods:
link:
config:
lifespan: 1h
base_url: http://localhost:4433
enabled: true
password:
enabled: true

flows:
error:
ui_url: http://localhost:3010/error

settings:
ui_url: http://localhost:3010/settings
privileged_session_max_age: 15m
required_aal: highest_available

recovery:
enabled: true
ui_url: http://localhost:3010/auth/recovery
use: link
after:
hooks:
- hook: revoke_active_sessions

verification:
enabled: false

logout:
after:
default_browser_return_url: http://localhost:3010/auth

login:
ui_url: http://localhost:3010/auth/login
lifespan: 10m

registration:
enabled: false

log:
level: debug
format: json
leak_sensitive_values: true

secrets:
cookie:
- PLEASE-CHANGE-ME-I-AM-VERY-INSECURE
cipher:
- 32-LONG-SECRET-NOT-SECURE-AT-ALL

ciphers:
algorithm: xchacha20-poly1305

hashers:
algorithm: bcrypt
bcrypt:
cost: 8

identity:
schemas:
- id: default
url: file:///etc/config/kratos/identity.schema.json

courier:
smtp:
connection_uri: smtps://test:test@mailslurper:1025/?skip_ssl_verify=true

session:
lifespan: 1h
cookie:
persistent: false
same_site: Strict
path: /
26 changes: 26 additions & 0 deletions localenv/happy-life-bank/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,42 @@ services:
hostname: happy-life-bank-admin
image: rafiki-frontend
pull_policy: never
volumes:
- type: bind
source: ../../packages/frontend/app
target: /home/rafiki/packages/frontend/app
read_only: true
restart: always
networks:
- rafiki
ports:
- '4010:4010'
environment:
PORT: 4010
LOG_LEVEL: debug
NODE_ENV: development
GRAPHQL_URL: http://happy-life-bank-backend:3001/graphql
OPEN_PAYMENTS_URL: https://happy-life-bank-backend/
ENABLE_INSECURE_MESSAGE_COOKIE: true
KRATOS_CONTAINER_PULIC_URL: 'http://happy-life-kratos:4433'
KRATOS_BROWSER_PUBLIC_URL: 'http://localhost:4432'
KRATOS_ADMIN_URL: 'http://happy-life-kratos:4434/admin'
depends_on:
- cloud-nine-admin
- happy-life-backend
- happy-life-kratos
happy-life-kratos:
build:
context: ../..
dockerfile: ./packages/frontend/kratos/Dockerfile
args:
PATH_TO_KRATOS_CONFIG: ./localenv/happy-life-bank/kratos.yml
depends_on:
- shared-database
- mailslurper
environment:
DEV_MODE: true
ports:
- "4432:4433"
networks:
- rafiki
91 changes: 91 additions & 0 deletions localenv/happy-life-bank/kratos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
version: v0.13.0

dsn: postgres://happy_life_kratos:kratos_password@shared-database:5432/happy_life_kratos?sslmode=disable&max_conns=20&max_idle_conns=4

serve:
public:
base_url: http://localhost:4432/
cors:
enabled: true
admin:
base_url: http://happy-life-kratos:4434/

selfservice:
default_browser_return_url: http://localhost:4010/
allowed_return_urls:
- http://localhost:4010

methods:
link:
config:
lifespan: 1h
base_url: http://localhost:4432
enabled: true
password:
enabled: true

flows:
error:
ui_url: http://localhost:4010/error

settings:
ui_url: http://localhost:4010/settings
privileged_session_max_age: 15m
required_aal: highest_available

recovery:
enabled: true
ui_url: http://localhost:4010/auth/recovery
use: link
after:
hooks:
- hook: revoke_active_sessions

verification:
enabled: false

logout:
after:
default_browser_return_url: http://localhost:4010/auth

login:
ui_url: http://localhost:4010/auth/login
lifespan: 10m

registration:
enabled: false

log:
level: debug
format: json
leak_sensitive_values: true

secrets:
cookie:
- PLEASE-CHANGE-ME-I-AM-VERY-INSECURE
cipher:
- 32-LONG-SECRET-NOT-SECURE-AT-ALL

ciphers:
algorithm: xchacha20-poly1305

hashers:
algorithm: bcrypt
bcrypt:
cost: 8

identity:
schemas:
- id: default
url: file:///etc/config/kratos/identity.schema.json

courier:
smtp:
connection_uri: smtps://test:test@mailslurper:1025/?skip_ssl_verify=true

session:
lifespan: 1h
cookie:
persistent: false
same_site: Strict
path: /
Binary file modified packages/documentation/public/img/localenv-architecture.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.