Skip to content

Commit c5b49be

Browse files
authored
Updated instructions to use the Okta CLI (#28)
1 parent 951abf8 commit c5b49be

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.env
12
/target/
23
!.mvn/wrapper/maven-wrapper.jar
34

@@ -22,4 +23,4 @@
2223
/nbbuild/
2324
/dist/
2425
/nbdist/
25-
/.nb-gradle/
26+
/.nb-gradle/

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,32 @@ yarn && yarn start
3838

3939
### Create an Application in Okta
4040

41-
You will need to [create an OIDC Application in Okta]() to get your values to perform authentication.
41+
Before you begin, you'll need a free Okta developer account. Install the [Okta CLI](https://cli.okta.com) and run `okta register` to sign up for a new account. If you already have an account, run `okta login`.
4242

43-
Log in to your Okta Developer account (or [sign up](https://developer.okta.com/signup/) if you don’t have an account) and navigate to **Applications** > **Add Application**. Click **Web**, click **Next**, and give the app a name you’ll remember. Specify `http://localhost:8080/login/oauth2/code/okta` as a Login redirect URI. Click **Done**, then click **Edit** to edit General Settings. Add `http://localhost:3000` and `http://localhost:8080` as Logout redirect URIs, then click **Save**.
43+
Then, run `okta apps create`. Select the default app name, or change it as you see fit. Choose **Web** and press **Enter**.
4444

45-
#### Server Configuration
45+
Select **Okta Spring Boot Starter**. Accept the default Redirect URI of `http://localhost:8080/login/oauth2/code/okta` and use `[http://localhost:3000,http://localhost:8080]` for the Logout Redirect URI.
46+
47+
The Okta CLI will create an OIDC Web App in your Okta Org. It will add the redirect URIs you specified and grant access to the Everyone group. You will see output like the following when it's finished:
48+
49+
```shell
50+
Okta application configuration has been written to:
51+
/path/to/app/src/main/resources/application.properties
52+
```
53+
54+
Open `src/main/resources/application.properties` to see the issuer and credentials for your app.
4655

47-
Set the `issuer` and copy the `clientId` and `clientSecret` into `src/main/resources/application.yml`.
56+
```properties
57+
okta.oauth2.issuer=https://dev-133337.okta.com/oauth2/default
58+
okta.oauth2.client-id=0oab8eb55Kb9jdMIr5d6
59+
okta.oauth2.client-secret=NEVER-SHOW-SECRETS
60+
```
61+
62+
NOTE: You can also use the Okta Admin Console to create your app. See [Create a Spring Boot App](https://developer.okta.com/docs/guides/sign-into-web-app/springboot/create-okta-application/) for more information.
4863

49-
**NOTE:** The value of `{yourOktaDomain}` should be something like `dev-123456.oktapreview.com`. Make sure you don't include `-admin` in the value!
64+
#### Server Configuration
65+
66+
Copy the values from `application.properties` into `src/main/resources/application.yml` and delete `application.properties`.
5067

5168
```yaml
5269
spring:
@@ -59,12 +76,14 @@ spring:
5976
okta:
6077
client-id: {clientId}
6178
client-secret: {clientSecret}
62-
scope: openid email profile
79+
scope: openid, email, profile
6380
provider:
6481
okta:
6582
issuer-uri: https://{yourOktaDomain}/oauth2/default
6683
```
6784
85+
Run `./mvnw spring-boot:run -Pprod` and log in to your app at `http://localhost:8080`.
86+
6887
## Links
6988

7089
This example uses the following open source libraries:

0 commit comments

Comments
 (0)