Skip to content

Commit 14b8061

Browse files
author
bnasslahsen
committed
project review
1 parent 450f60b commit 14b8061

File tree

149 files changed

+3792
-20
lines changed

Some content is hidden

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

149 files changed

+3792
-20
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
# Spring-boot with OpenAPI Demo applications.
55

6-
## [Demo Spring Boot 2 webmvc with OpenAPI 3](https://springdoc-openapi-test-app2-silly-numbat.eu-de.mybluemix.net/).
7-
## [Demo Spring Boot 2 webflux with OpenAPI 3](https://springdoc-openapi-test-app3-terrific-rabbit.eu-de.mybluemix.net/swagger-ui.html).
8-
## [Demo Spring Boot 2 webmvc with OpenAPI 3](https://springdoc-openapi-test-app1-courteous-puku.eu-de.mybluemix.net/).
6+
## [Demo Spring Boot 2 webmvc with OpenAPI 3](https://springdoc-openapi-spring-boot-2-webmvc-silly-numbat.eu-de.mybluemix.net/).
7+
## [Demo Spring Boot 2 webflux with OpenAPI 3](https://springdoc-openapi-spring-boot-2-webflux-terrific-rabbit.eu-de.mybluemix.net/swagger-ui.html).
8+
## [Demo Spring Boot 2 webmvc with OpenAPI 3](https://springdoc-openapi-spring-boot-1-courteous-puku.eu-de.mybluemix.net/).
99

1010

1111
![Branching](https://springdoc.github.io/springdoc-openapi-demos/assets/images/pets.png)

manifest.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
---
22
applications:
3-
- name: springdoc-openapi-test-app1
3+
- name: springdoc-openapi-spring-boot-1
44
random-route: true
55
memory: 400m
6-
path: springdoc-openapi-test-app1-cf.jar
6+
path: springdoc-openapi-spring-boot-1-cf.jar
77
env:
88
JAVA_OPTS: '-XX:MaxMetaspaceSize=80780K -Xss512k -Xmx200M -XX:ReservedCodeCacheSize=16M -XX:MaxDirectMemorySize=16M'
99
JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 1.8.0_212 } }'
1010
buildpack: java_buildpack
11-
- name: springdoc-openapi-test-app2
11+
- name: springdoc-openapi-spring-boot-2-webmvc
1212
random-route: true
1313
memory: 400m
14-
path: springdoc-openapi-test-app2-cf.jar
14+
path: springdoc-openapi-spring-boot-2-webmvc-cf.jar
1515
env:
1616
JAVA_OPTS: '-XX:MaxMetaspaceSize=80780K -Xss512k -Xmx200M -XX:ReservedCodeCacheSize=16M -XX:MaxDirectMemorySize=16M'
1717
JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 1.8.0_212 } }'
1818
buildpack: java_buildpack
19-
- name: springdoc-openapi-test-app3
19+
- name: springdoc-openapi-spring-boot-2-webflux
2020
random-route: true
2121
memory: 400m
22-
path: springdoc-openapi-test-app3-cf.jar
22+
path: springdoc-openapi-spring-boot-2-webflux-cf.jar
2323
env:
2424
JAVA_OPTS: '-XX:MaxMetaspaceSize=80780K -Xss512k -Xmx200M -XX:ReservedCodeCacheSize=16M -XX:MaxDirectMemorySize=16M'
2525
JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 1.8.0_212 } }'
2626
buildpack: java_buildpack
27-
- name: springdoc-openapi-test-app4
27+
- name: springdoc-openapi-spring-boot-2-webflux-functional
2828
random-route: true
2929
memory: 400m
30-
path: springdoc-openapi-test-app4-cf.jar
30+
path: springdoc-openapi-spring-boot-2-webflux-functional-cf.jar
3131
env:
3232
JAVA_OPTS: '-XX:MaxMetaspaceSize=80780K -Xss512k -Xmx200M -XX:ReservedCodeCacheSize=16M -XX:MaxDirectMemorySize=16M'
3333
JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 1.8.0_212 } }'

pom.xml

+6-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@
4646
</distributionManagement>
4747

4848
<modules>
49-
<module>springdoc-openapi-test-app1</module>
50-
<module>springdoc-openapi-test-app2</module>
51-
<module>springdoc-openapi-test-app3</module>
52-
<module>spring-boot-springdoc</module>
53-
<module>springdoc-openapi-test-app4</module>
49+
<module>springdoc-openapi-spring-boot-1</module>
50+
<module>springdoc-openapi-spring-boot-2-webmvc</module>
51+
<module>springdoc-openapi-spring-boot-2-webflux</module>
52+
<module>springdoc-openapi-spring-boot-2-webflux-functional</module>
53+
<module>sample-springdoc-openapi-book-service</module>
54+
<module>sample-springdoc-openapi-oauth2</module>
5455
</modules>
5556

5657
<properties>
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Spring Security OAuth - New Stack
2+
3+
### Relevant information:
4+
5+
1. `oauth-authorization-server` is a Keycloak Authorization Server wrapped as a Spring Boot application
6+
2. There is one OAuth Client registered in the Authorization Server:
7+
1. Client Id: newClient
8+
2. Client secret: newClientSecret
9+
3. Redirect Uri: http://localhost:8089/
10+
2. There are two OAuth Angular Front-end Apps:
11+
1. `oauth-ui-authorization-code-angular` - A simple Angular App
12+
2. `oauth-ui-authorization-code-angular-zuul` - An Angular App hosted as a Boot Application with embedded Zuul proxy
13+
3. `oauth-resource-server` is a Spring Boot based RESTFul API, acting as a backend Application
14+
4. There are two users registered in the Authorization Server:
15+
1. john@test.com / 123
16+
2. mike@other.com / pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.springdoc</groupId>
7+
<artifactId>oauth-authorization-server</artifactId>
8+
<version>0.1.0-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<parent>
12+
<groupId>org.springframework.boot</groupId>
13+
<artifactId>spring-boot-starter-parent</artifactId>
14+
<version>2.2.2.RELEASE</version>
15+
<relativePath /> <!-- lookup parent from repository -->
16+
</parent>
17+
18+
<dependencies>
19+
20+
<!-- web -->
21+
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-web</artifactId>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-actuator</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-devtools</artifactId>
35+
</dependency>
36+
37+
<!-- persistence -->
38+
39+
<dependency>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-starter-data-jpa</artifactId>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>com.h2database</groupId>
46+
<artifactId>h2</artifactId>
47+
<scope>runtime</scope>
48+
</dependency>
49+
50+
<!-- Keycloak server -->
51+
52+
<dependency>
53+
<groupId>org.jboss.resteasy</groupId>
54+
<artifactId>resteasy-jaxb-provider</artifactId>
55+
<version>${resteasy.version}</version>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>org.jboss.resteasy</groupId>
60+
<artifactId>resteasy-jackson2-provider</artifactId>
61+
<version>${resteasy.version}</version>
62+
</dependency>
63+
64+
<dependency>
65+
<groupId>org.infinispan</groupId>
66+
<artifactId>infinispan-core</artifactId>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>org.keycloak</groupId>
71+
<artifactId>keycloak-model-infinispan</artifactId>
72+
<version>${keycloak.version}</version>
73+
</dependency>
74+
75+
<dependency>
76+
<groupId>org.keycloak</groupId>
77+
<artifactId>keycloak-services</artifactId>
78+
<version>${keycloak.version}</version>
79+
<exclusions>
80+
<exclusion>
81+
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
82+
<groupId>org.jboss.spec.javax.servlet</groupId>
83+
</exclusion>
84+
</exclusions>
85+
</dependency>
86+
87+
<dependency>
88+
<groupId>org.jboss.modules</groupId>
89+
<artifactId>jboss-modules</artifactId>
90+
<version>${jboss.modules}</version>
91+
</dependency>
92+
93+
<dependency>
94+
<groupId>org.keycloak</groupId>
95+
<artifactId>keycloak-model-jpa</artifactId>
96+
<version>${keycloak.version}</version>
97+
</dependency>
98+
99+
<dependency>
100+
<groupId>org.keycloak</groupId>
101+
<artifactId>keycloak-js-adapter</artifactId>
102+
<version>${keycloak.version}</version>
103+
</dependency>
104+
105+
<dependency>
106+
<groupId>org.keycloak</groupId>
107+
<artifactId>keycloak-themes</artifactId>
108+
<version>${keycloak.version}</version>
109+
</dependency>
110+
111+
<dependency>
112+
<groupId>org.keycloak</groupId>
113+
<artifactId>keycloak-saml-core</artifactId>
114+
<version>${keycloak.version}</version>
115+
</dependency>
116+
117+
<dependency>
118+
<groupId>org.keycloak</groupId>
119+
<artifactId>keycloak-authz-policy-common</artifactId>
120+
<version>${keycloak.version}</version>
121+
</dependency>
122+
123+
<dependency>
124+
<groupId>org.keycloak</groupId>
125+
<artifactId>keycloak-wildfly-extensions</artifactId>
126+
<version>${keycloak.version}</version>
127+
</dependency>
128+
129+
<dependency>
130+
<groupId>org.freemarker</groupId>
131+
<artifactId>freemarker</artifactId>
132+
</dependency>
133+
134+
<!-- config properties processor -->
135+
<dependency>
136+
<groupId>org.springframework.boot</groupId>
137+
<artifactId>spring-boot-configuration-processor</artifactId>
138+
<optional>true</optional>
139+
</dependency>
140+
141+
<!-- test -->
142+
143+
<dependency>
144+
<groupId>org.springframework.boot</groupId>
145+
<artifactId>spring-boot-starter-test</artifactId>
146+
<scope>test</scope>
147+
</dependency>
148+
149+
<dependency>
150+
<groupId>io.rest-assured</groupId>
151+
<artifactId>rest-assured</artifactId>
152+
<scope>test</scope>
153+
</dependency>
154+
</dependencies>
155+
156+
<build>
157+
<plugins>
158+
<plugin>
159+
<groupId>org.springframework.boot</groupId>
160+
<artifactId>spring-boot-maven-plugin</artifactId>
161+
</plugin>
162+
<plugin>
163+
<groupId>org.apache.maven.plugins</groupId>
164+
<artifactId>maven-surefire-plugin</artifactId>
165+
<configuration>
166+
<excludes>
167+
<exclude>**/*LiveTest.java</exclude>
168+
</excludes>
169+
</configuration>
170+
</plugin>
171+
</plugins>
172+
</build>
173+
174+
<properties>
175+
<!-- non-dependencies -->
176+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
177+
<java.version>1.8</java.version>
178+
179+
<keycloak.version>8.0.0</keycloak.version>
180+
<resteasy.version>3.9.0.Final</resteasy.version>
181+
<jboss.modules>1.9.2.Final</jboss.modules>
182+
</properties>
183+
184+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.springdoc.demo.auth;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
8+
import org.springframework.boot.autoconfigure.web.ServerProperties;
9+
import org.springframework.boot.context.event.ApplicationReadyEvent;
10+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
11+
import org.springframework.context.ApplicationListener;
12+
import org.springframework.context.annotation.Bean;
13+
14+
import org.springdoc.demo.auth.config.KeycloakServerProperties;
15+
16+
@SpringBootApplication(exclude = LiquibaseAutoConfiguration.class)
17+
@EnableConfigurationProperties(KeycloakServerProperties.class)
18+
public class AuthorizationServerApp {
19+
20+
private static final Logger LOG = LoggerFactory.getLogger(AuthorizationServerApp.class);
21+
22+
public static void main(String[] args) throws Exception {
23+
SpringApplication.run(AuthorizationServerApp.class, args);
24+
}
25+
26+
@Bean
27+
ApplicationListener<ApplicationReadyEvent> onApplicationReadyEventListener(ServerProperties serverProperties, KeycloakServerProperties keycloakServerProperties) {
28+
29+
return (evt) -> {
30+
31+
Integer port = serverProperties.getPort();
32+
String keycloakContextPath = keycloakServerProperties.getContextPath();
33+
34+
LOG.info("Embedded Keycloak started: http://localhost:{}{} to use keycloak", port, keycloakContextPath);
35+
};
36+
}
37+
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package org.springdoc.demo.auth.config;
2+
3+
import org.keycloak.models.KeycloakSession;
4+
import org.keycloak.representations.idm.RealmRepresentation;
5+
import org.keycloak.services.managers.ApplianceBootstrap;
6+
import org.keycloak.services.managers.RealmManager;
7+
import org.keycloak.services.resources.KeycloakApplication;
8+
import org.keycloak.util.JsonSerialization;
9+
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
11+
import org.springframework.core.io.ClassPathResource;
12+
import org.springframework.core.io.Resource;
13+
14+
import org.springdoc.demo.auth.config.KeycloakServerProperties.AdminUser;
15+
16+
public class EmbeddedKeycloakApplication extends KeycloakApplication {
17+
18+
private static final Logger LOG = LoggerFactory.getLogger(EmbeddedKeycloakApplication.class);
19+
20+
static KeycloakServerProperties keycloakServerProperties;
21+
22+
public EmbeddedKeycloakApplication() {
23+
24+
super();
25+
26+
createMasterRealmAdminUser();
27+
28+
createSpringdocRealm();
29+
}
30+
31+
private void createMasterRealmAdminUser() {
32+
33+
KeycloakSession session = getSessionFactory().create();
34+
35+
ApplianceBootstrap applianceBootstrap = new ApplianceBootstrap(session);
36+
37+
AdminUser admin = keycloakServerProperties.getAdminUser();
38+
39+
try {
40+
session.getTransactionManager().begin();
41+
applianceBootstrap.createMasterRealmUser(admin.getUsername(), admin.getPassword());
42+
session.getTransactionManager().commit();
43+
} catch (Exception ex) {
44+
LOG.warn("Couldn't create keycloak master admin user: {}", ex.getMessage());
45+
session.getTransactionManager().rollback();
46+
}
47+
48+
session.close();
49+
}
50+
51+
private void createSpringdocRealm() {
52+
KeycloakSession session = getSessionFactory().create();
53+
54+
try {
55+
session.getTransactionManager().begin();
56+
57+
RealmManager manager = new RealmManager(session);
58+
Resource lessonRealmImportFile = new ClassPathResource(keycloakServerProperties.getRealmImportFile());
59+
60+
manager.importRealm(
61+
JsonSerialization.readValue(lessonRealmImportFile.getInputStream(), RealmRepresentation.class));
62+
63+
session.getTransactionManager().commit();
64+
} catch (Exception ex) {
65+
LOG.warn("Failed to import Realm json file: {}", ex.getMessage());
66+
session.getTransactionManager().rollback();
67+
}
68+
69+
session.close();
70+
}
71+
}

0 commit comments

Comments
 (0)