Skip to content

Commit 679c5a1

Browse files
committed
2024 edition
0 parents  commit 679c5a1

File tree

65 files changed

+4351
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4351
-0
lines changed

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
34+
35+
36+
application-default.properties
37+
V01.*__migration*.sql
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# OAuth2/OIDC SSO Demo with Spring Boot + Spring Security
2+
3+
This demo app consists of following three components:
4+
5+
* [Authorization](authorization) ... OAuth2/OIDC Authorization Server. Using [Spring Authorization Server](https://docs.spring.io/spring-authorization-server/reference/index.html).
6+
* [Todo API](todo-api) ... OAuth2 Resource Server. Provides REST API. Using [Spring Security's OAuth2 Resource Server](https://docs.spring.io/spring-security/reference/6.4/servlet/oauth2/resource-server/index.html).
7+
* [Todo UI](todo-ui) ... Web UI (React) backed by [Spring Security's OAuth2 Login](https://docs.spring.io/spring-security/reference/6.4/servlet/oauth2/login/index.html) + [OAuth 2.0 Client](https://docs.spring.io/spring-security/reference/6.4/servlet/oauth2/client/index.html).
8+
9+
## How to run
10+
11+
Java 21+ and docker are required.
12+
13+
```
14+
./mvnw clean spring-boot:run -f authorization -Dspring-boot.run.arguments="--spring.docker.compose.enabled=true --spring.docker.compose.file=$(pwd)/compose.yaml"
15+
./mvnw clean spring-boot:run -f todo-api -Dspring-boot.run.arguments="--spring.docker.compose.enabled=true --spring.docker.compose.file=$(pwd)/compose.yaml"
16+
./mvnw clean spring-boot:run -f todo-ui -Dspring-boot.run.arguments="--spring.docker.compose.enabled=true --spring.docker.compose.file=$(pwd)/compose.yaml"
17+
```
18+
19+
Visit http://localhost:8080 (todo-ui). The first time you visit, you will be redirected to http://127.0.0.1:9000 (authorization).
20+
21+
<img width="1024" alt="image" src="https://github.com/user-attachments/assets/5f2764a8-4fde-41be-b0e6-d21f04d7fdeb">
22+
23+
* Username: `[email protected]`
24+
* Password: `password`
25+
26+
<img width="1024" alt="image" src="https://github.com/user-attachments/assets/c4933de2-1895-4c08-8f11-d6c67dcc2f34">
27+
28+
Feel free to add new Todos or complete them.
29+
30+
<img width="1024" alt="image" src="https://github.com/user-attachments/assets/9e115ad3-3e5a-4d69-a418-695c1e3e15e7">
31+
32+
You can see the tracing via Zipkin (http://localhost:9411)
33+
34+
<img width="1024" alt="image" src="https://github.com/user-attachments/assets/1cdfaec6-affe-4baf-aec2-6592c8716e3f">
35+
<img width="1024" alt="image" src="https://github.com/user-attachments/assets/4a0b15e5-a89f-4010-bac7-3f877208c83d">
36+
37+
Docker Compose will automatically start up when the app is started, but it will not automatically shut down, so if you do not need Zipkin after stopping the app, please shut down Docker Compose as well.
38+
39+
```
40+
pkill -TERM java
41+
docker compose down
42+
```

authorization/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/mvnw text eol=lf
2+
*.cmd text eol=crlf

authorization/.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

authorization/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
```
3+
pushd src/main/resources
4+
openssl genrsa -out private.pem 2048
5+
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
6+
openssl pkcs8 -topk8 -inform PEM -in private.pem -out private_key.pem -nocrypt
7+
rm -f private.pem
8+
popd
9+
```
10+
11+
12+
```
13+
cat <<EOF | sudo tee -a /etc/hosts
14+
127.0.0.1 host.docker.internal
15+
EOF
16+
17+
ISSUER_URL=http://host.docker.internal:9000
18+
CLIENT_ID=dex-example-app
19+
CLIENT_SECRET=dex
20+
docker run --rm -p 5555:5555 obitech/dex-example-app --debug --issuer ${ISSUER_URL} --listen http://0.0.0.0:5555 --client-id ${CLIENT_ID} --client-secret ${CLIENT_SECRET} --redirect-uri=http://localhost:5555/callback
21+
```

0 commit comments

Comments
 (0)