You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-23Lines changed: 33 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,14 +14,14 @@ The goal of this project is to implement an application where a user can manage
14
14
15
15
-### jobs-api
16
16
17
-
[`Spring Boot`](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/) Web Java application that exposes a REST API for managing jobs. It has some endpoints that are secured. `jobs-api` uses `Okta` to handle authentication and authorization.
17
+
[`Spring Boot`](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/) Web Java application that exposes a REST API for managing jobs. It has some endpoints that are secured. `Okta` is used to handle authentication and authorization.
18
18
19
-
The table below shows the endpoins, each one are secured or not and the authorization role required to access the secured ones.
19
+
The table below shows the endpoins, whether they are secured or not, and the authorization role required to access the secured ones.
@@ -67,12 +67,12 @@ The picture below is how `Okta Admin Dashboard` looks like
67
67
- General Settings
68
68
- App integration name: `Jobs Portal SPA`
69
69
- Grant type: check `Authorization Code` and `Implicit (hybrid)`
70
-
- Sign-in redirect URIs: `http://localhost:3000/implicit/callback` and `http://localhost:8080/authenticate`
70
+
- Sign-in redirect URIs: `http://localhost:3000/implicit/callback` and `http://localhost:8080/callback/token`
71
71
- Sign-out redirect URIs: `http://localhost:3000`
72
72
- Assignments
73
73
- Controlled access: `Skip group assignment for now`
74
74
- Click `Save` button
75
-
- On the next screen, it's shown the 2 important values we will need to configure and run the `Jobs Portal SPA`: `Client ID` and `Okta Domain`
75
+
- On the next screen, the `Client ID`and `Okta Domain` of `Jobs Portal SPA` are displayed.
76
76
77
77
### Create groups
78
78
@@ -93,8 +93,8 @@ The picture below is how `Okta Admin Dashboard` looks like
93
93
- Enter the following information for the Staff person
94
94
- First name: `Mario`
95
95
- Last name: `Bros`
96
-
- Username: `mario.bros@jobs.com`
97
-
- Primary email: `mario.bros@jobs.com`
96
+
- Username: `mario.bros@test.com`
97
+
- Primary email: `mario.bros@test.com`
98
98
- Groups: `JOBS_STAFF` (the group will popup; select it to add it)
99
99
- Password: `Set by admin`
100
100
- Set a strong password in the text-field that will appear
@@ -103,8 +103,8 @@ The picture below is how `Okta Admin Dashboard` looks like
103
103
- Enter the following information for the Customer person
104
104
- First name: `Luigi`
105
105
- Last name: `Bros`
106
-
- Username: `luigi.bros@jobs.com`
107
-
- Primary email: `luigi.bros@jobs.com`
106
+
- Username: `luigi.bros@test.com`
107
+
- Primary email: `luigi.bros@test.com`
108
108
- Groups: `JOBS_CUSTOMER` (the group will popup; select it to add it)
109
109
- Password: `Set by admin`
110
110
- Set a strong password in the text-field that will appear
@@ -159,7 +159,7 @@ The picture below is how `Okta Admin Dashboard` looks like
159
159
160
160
- In a terminal, navigate to `okta-springboot-react/jobs-api` folder
161
161
162
-
- Export the following environment variables. Those values were obtained while (adding Application)[#add-application]
162
+
- Export the following environment variables. Those values were obtained while [adding Application](#add-application)
163
163
```
164
164
export OKTA_CLIENT_ID=...
165
165
export OKTA_DOMAIN=...
@@ -174,7 +174,7 @@ The picture below is how `Okta Admin Dashboard` looks like
174
174
175
175
- Open a new terminal and navigate to `okta-springboot-react/jobs-ui` folder
176
176
177
-
- Create a file called `.env.local` with the following content. Those values were obtained while (adding Application)[#add-application]
177
+
- Create a file called `.env.local` with the following content. Those values were obtained while [adding Application](#add-application)
178
178
```
179
179
REACT_APP_OKTA_CLIENT_ID=<OKTA_CLIENT_ID>
180
180
REACT_APP_OKTA_ORG_URL=https://<OKTA_DOMAIN>
@@ -208,23 +208,23 @@ The picture below is how `Okta Admin Dashboard` looks like
208
208
209
209
- Done!
210
210
211
-
> **Note:** If you are using the person `luigi.bros@jobs.com`, you will not be able to create/update/delete a job because it doesn't have the required role for it.
211
+
> **Note:** If you are using the person `luigi.bros@test.com`, you will not be able to create/update/delete a job because it doesn't have the required role for it.
212
212
213
213
## Getting Access Token
214
214
215
-
In order to use just the `jobs-api` endpoints, you must have an access token. Below are the steps to get it.
215
+
In order to use just the `jobs-api` endpoints, you must have an `JWT` access token. Below are the steps to get it.
216
216
217
-
- In a terminal, create the following environment variables. Those values were obtained while (adding Application)[#add-application]
217
+
- In a terminal, create the following environment variables. Those values were obtained while [adding Application][#add-application]
@@ -234,15 +234,25 @@ In order to use just the `jobs-api` endpoints, you must have an access token. Be
234
234
echo $OKTA_ACCESS_TOKEN_URL
235
235
```
236
236
237
-
- Copy the Okta Access Token Url from the previous step and past it in a browser
237
+
- Copy the Okta Access Token Url from the previous step and paste it in a browser
238
238
239
239
- The Okta login page will appear. Enter the username & password of the person added at the step [`Configuring Okta > Add people`](#add-people) and click `Sign In` button
240
240
241
-
- It will redirect to `authenticate` endpoint of `jobs-api` and the `Access token` will be displayed.
241
+
- It will redirect to `/callback/token` endpoint of `jobs-api` and the `Access token` will be displayed, together with other information
242
+
```
243
+
{
244
+
"state": "state",
245
+
"access_token": "eyJraWQiOiJyNFdY...",
246
+
"token_type": "Bearer",
247
+
"expires_in": "3600",
248
+
"scope": "openid"
249
+
}
250
+
```
251
+
> **Tip:** In [jwt.io](https://jwt.io), you can decode and verify the `JWT` access token
242
252
243
253
## Calling jobs-api endpoints using curl
244
254
245
-
- **`GET api/jobs/newest`**
255
+
- **`GET /api/jobs/newest`**
246
256
247
257
The `api/jobs/newest` endpoint is public, so we can access it without any problem.
248
258
```
@@ -254,7 +264,7 @@ In order to use just the `jobs-api` endpoints, you must have an access token. Be
Try to get the list of jobs without informing the access token.
260
270
```
@@ -265,7 +275,7 @@ In order to use just the `jobs-api` endpoints, you must have an access token. Be
265
275
HTTP/1.1 401
266
276
```
267
277
268
-
- **`GET api/jobs` with Access Token**
278
+
- **`GET /api/jobs` with Access Token**
269
279
270
280
First, get the access token as explained in [`Getting Access Token`](#getting-access-token) section. Then, create an environment variable for the access token.
271
281
```
@@ -282,7 +292,7 @@ In order to use just the `jobs-api` endpoints, you must have an access token. Be
> **Note:** If you are using the person `luigi.bros@jobs.com`, you will not be able to create/update/delete a job because it doesn't have the required role for it.
295
+
> **Note:** If you are using the person `luigi.bros@test.com`, you will not be able to create/update/delete a job because it doesn't have the required role for it.
286
296
287
297
## Using jobs-api with Swagger
288
298
@@ -294,7 +304,7 @@ In order to use just the `jobs-api` endpoints, you must have an access token. Be
294
304
295
305
- Done! You can now access the sensitive endpoints.
296
306
297
-
> **Note:** If you are using the person `luigi.bros@jobs.com`, you will not be able to create/update/delete a job because it doesn't have the required role for it.
307
+
> **Note:** If you are using the person `luigi.bros@test.com`, you will not be able to create/update/delete a job because it doesn't have the required role for it.
0 commit comments