Skip to content

Commit

Permalink
Update samples to use okta spring boot starter and spring boot 3 (#30)
Browse files Browse the repository at this point in the history
* Update samples to use okta spring boot starter and spring boot 3

* udpate to gradle 8.4

* remove @EnableWebSecurity as it is not needed

* update machine image

* try older node image and install java 17

* update config.yml

* update config.yml

* remove nvm install - test script needs change

* update quickstarts-test version

* use API_IDENTIFIER in application.yml example

* Update 01-Authorization-WebFlux/build.gradle

Co-authored-by: Frederik Prijck <[email protected]>

* Update 01-Authorization-MVC/build.gradle

Co-authored-by: Frederik Prijck <[email protected]>

---------

Co-authored-by: Frederik Prijck <[email protected]>
  • Loading branch information
jimmyjames and frederikprijck authored Oct 26, 2023
1 parent 9288dd1 commit b6d4229
Show file tree
Hide file tree
Showing 24 changed files with 289 additions and 376 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Common Logic
machine: &machine-cfg
image: ubuntu-2004:202107-02
image: ubuntu-2204:2023.10.1

version: 2.1

Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
- checkout
- run:
name: Clone test script
command: git clone -b v0.0.1 --depth 1 https://github.com/auth0-samples/api-quickstarts-tests test
command: git clone -b v0.0.3 --depth 1 https://github.com/auth0-samples/api-quickstarts-tests test
- persist_to_workspace:
root: ~/
paths:
Expand Down
2 changes: 1 addition & 1 deletion 01-Authorization-MVC/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gradle:5.4.1-jdk8
FROM gradle:8.4-jdk17

WORKDIR /tmp
ADD . /tmp
Expand Down
21 changes: 8 additions & 13 deletions 01-Authorization-MVC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

This sample demonstrates:

- Configuring a Spring Boot MVC application as a Resource Server
- Using and extending Spring Security to validate JWTs
- Using the [Okta Spring Boot Starter](https://github.com/okta/okta-spring-boot) to configure a Spring Boot Servlet Resource Server
- Protecting APIs to only allow authorized access

## Prerequisites

- Java 8 or greater
- Java 17 or greater
- An Auth0 account

## Setup
Expand All @@ -26,16 +25,12 @@ The project needs to be configured with your Auth0 domain and API Identifier.
To do this, first copy `src/main/resources/application.yml.example` into a new file in the same folder called `src/main/resources/application.yml`, and replace the values with your own Auth0 domain and API Identifier:

```yaml
auth0:
audience: {API_IDENTIFIER}

spring:
security:
oauth2:
resourceserver:
jwt:
# Note the trailing slash is important!
issuer-uri: https://{DOMAIN}/
okta:
oauth2:
# Replace with the domain of your Auth0 tenant.
issuer: https://{DOMAIN}/
# Replace with the API Identifier for your Auth0 API.
audience: {AUDIENCE}
```
## Running
Expand Down
11 changes: 7 additions & 4 deletions 01-Authorization-MVC/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ buildscript {

plugins {
id 'java'
id 'org.springframework.boot' version '2.7.0'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
}

group = 'com.auth0'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

java {
sourceCompatibility = '17'
}

repositories {
mavenCentral()
}

dependencies {
implementation 'com.okta.spring:okta-spring-boot-starter:3.0.5'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'

testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand Down
Binary file modified 01-Authorization-MVC/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit b6d4229

Please sign in to comment.