Skip to content

Commit e57e5b7

Browse files
authored
Feat add custom id claim (netbirdio#129)
* Fix management API endpoint ENV var. Format README. * Add and use id_current user flag * Use mix of the new and old methods to detect current user.
1 parent 2c4ada0 commit e57e5b7

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

README.md

+28-9
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,43 @@ Disclaimer. We believe that proper user management system is not a trivial task
3636
use Auth0 service that covers all our needs (user management, social login, JTW for the management API).
3737
Auth0 so far is the only 3rd party dependency that can't be really self-hosted.
3838

39-
1. install [Docker](https://docs.docker.com/get-docker/)
40-
2. register [Auth0](https://auth0.com/) account
41-
3. running Wiretrustee UI Dashboard requires the following Auth0 environmental variables to be set (see docker command below):
39+
1. Install [Docker](https://docs.docker.com/get-docker/)
40+
2. Register [Auth0](https://auth0.com/) account
41+
3. Running Wiretrustee UI Dashboard requires the following Auth0 environmental variables to be set (see docker command below):
4242

43-
```AUTH0_DOMAIN``` ```AUTH0_CLIENT_ID``` ```AUTH0_AUDIENCE```
43+
`AUTH0_DOMAIN` `AUTH0_CLIENT_ID` `AUTH0_AUDIENCE`
4444

4545
To obtain these, please use [Auth0 React SDK Guide](https://auth0.com/docs/quickstart/spa/react/01-login#configure-auth0) up until "Configure Allowed Web Origins"
4646

47-
4. Wiretrustee UI Dashboard uses Wiretrustee Management Service HTTP API, so setting ```WIRETRUSTEE_MGMT_API_ENDPOINT``` is required. Most likely it will be ```http://localhost:33071``` if you are hosting Management API on the same server.
47+
4. Wiretrustee UI Dashboard uses Wiretrustee Management Service HTTP API, so setting `NETBIRD_MGMT_API_ENDPOINT` is required. Most likely it will be `http://localhost:33071` if you are hosting Management API on the same server.
4848
5. Run docker container without SSL (Let's Encrypt):
4949

50-
```docker run -d --name wiretrustee-dashboard --rm -p 80:80 -p 443:443 -e AUTH0_DOMAIN=<SET YOUR AUTH DOMAIN> -e AUTH0_CLIENT_ID=<SET YOUR CLIENT ID> -e AUTH0_AUDIENCE=<SET YOUR AUDIENCE> -e WIRETRUSTEE_MGMT_API_ENDPOINT=<SET YOUR MANAGEMETN API URL> wiretrustee/dashboard:main```
50+
```shell
51+
docker run -d --name wiretrustee-dashboard \
52+
--rm -p 80:80 -p 443:443 \
53+
-e AUTH0_DOMAIN=<SET YOUR AUTH DOMAIN> \
54+
-e AUTH0_CLIENT_ID=<SET YOUR CLIENT ID> \
55+
-e AUTH0_AUDIENCE=<SET YOUR AUDIENCE> \
56+
-e NETBIRD_MGMT_API_ENDPOINT=<SET YOUR MANAGEMETN API URL> \
57+
wiretrustee/dashboard:main
58+
```
5159
6. Run docker container with SSL (Let's Encrypt):
5260

53-
```docker run -d --name wiretrustee-dashboard --rm -p 80:80 -p 443:443 -e NGINX_SSL_PORT=443 -e LETSENCRYPT_DOMAIN=<YOUR PUBLIC DOMAIN> -e LETSENCRYPT_EMAIL=<YOUR EMAIL> -e AUTH0_DOMAIN=<SET YOUR AUTH DOMAIN> -e AUTH0_CLIENT_ID=<SET YOUR CLEITN ID> -e AUTH0_AUDIENCE=<SET YOUR AUDIENCE> -e WIRETRUSTEE_MGMT_API_ENDPOINT=<SET YOUR MANAGEMETN API URL> wiretrustee/dashboard:main```
61+
```shell
62+
docker run -d --name wiretrustee-dashboard \
63+
--rm -p 80:80 -p 443:443 \
64+
-e NGINX_SSL_PORT=443 \
65+
-e LETSENCRYPT_DOMAIN=<YOUR PUBLIC DOMAIN> \
66+
-e LETSENCRYPT_EMAIL=<YOUR EMAIL> \
67+
-e AUTH0_DOMAIN=<SET YOUR AUTH DOMAIN> \
68+
-e AUTH0_CLIENT_ID=<SET YOUR CLEITN ID> \
69+
-e AUTH0_AUDIENCE=<SET YOUR AUDIENCE> \
70+
-e NETBIRD_MGMT_API_ENDPOINT=<SET YOUR MANAGEMETN API URL> \
71+
wiretrustee/dashboard:main
72+
```
5473

5574
## How to run local development
5675
1. Install node 16
57-
2. create and update the src/.local-config.json file. This file should contain values to be replaced from src/config.json
76+
2. create and update the `src/.local-config.json` file. This file should contain values to be replaced from `src/config.json`
5877
3. run `npm install`
59-
4. run `npm run start dev`
78+
4. run `npm run start dev`

src/components/Navbar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ const Navbar = () => {
9191
runUser = idTokenPayload
9292
}
9393
setIsRefreshingUserState(false)
94-
if (runUser && runUser.sub) {
95-
const found = users.find(u => u.id == runUser.sub)
94+
if (runUser) {
95+
const found = users.find(u => u.is_current ? u.is_current : runUser.sub ? u.id == runUser.sub : false)
9696
if (found) {
9797
setCurrentUser(found)
9898
}

src/components/UserUpdate.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ const UserUpdate = () => {
233233
role: "",
234234
status: "",
235235
auto_groups: [],
236-
name: user.name
236+
name: user.name,
237+
is_current: user.is_current,
237238
} as User));
238239
setFormUser({} as FormUser)
239240
toggleEditName(false)

src/store/user/types.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ export interface User {
33
email?: string;
44
name: string;
55
role: string;
6-
status: string
7-
auto_groups: string[]
6+
status: string;
7+
auto_groups: string[];
8+
is_current?: boolean;
89
}
910

1011
export interface FormUser extends User {
1112
autoGroupsNames: string[]
1213
}
1314

14-
export interface UserToSave extends User
15-
{
15+
export interface UserToSave extends User {
1616
groupsToCreate: string[]
17-
}
17+
}

0 commit comments

Comments
 (0)