Skip to content

Commit 09a2617

Browse files
authored
Keycloak oidc (#15)
added back keycloak odic added report-service resourceserver
1 parent 5038c86 commit 09a2617

File tree

63 files changed

+3487
-940
lines changed

Some content is hidden

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

63 files changed

+3487
-940
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Spring MVC:
2929
- favicon handler
3030

3131
Security:
32-
- Account management
32+
- Account management with KeyCloak
3333
- Spring Security
3434
- User/User_Authority entity and repository/services
3535
- login, logout, home pages based on user role
@@ -108,12 +108,12 @@ It contains following applications:
108108

109109
# Note you will need to create a database named 'seedapp' in your mysql server
110110

111-
Option 1 - run with manually started ActiveMQ and MySQL servers
111+
Option 1 - run with manually started KeyCloak, ActiveMQ and MySQL servers
112112
- Run ```mvn clean install``` at root
113113
- Run ```docker-compose -f config/docker-compose.yml up``` at root to start docker containers
114114
- Go to main-app folder and run ```mvn``` to start the application
115115

116-
Option 2 - automatically start ActiveMQ and MySQL using TestContainer while application is starting
116+
Option 2 - automatically start KeyCloak, ActiveMQ and MySQL using TestContainer while application is starting
117117
- Run ```mvn clean install``` at root
118118
- Go to main-app folder and run ```mvn -Pdev,withTestContainer``` to start the application
119119

config/docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ services:
3838
- 9411:9411
3939
networks:
4040
- seedappnet
41+
keycloak:
42+
image: 'quay.io/keycloak/keycloak:23.0.3'
43+
container_name: keycloak
44+
command: start-dev --import-realm
45+
environment:
46+
- KEYCLOAK_DB=dev-file
47+
- KEYCLOAK_ADMIN=admin
48+
- KEYCLOAK_ADMIN_PASSWORD=admin
49+
- KEYCLOAK_FEATURES=scripts
50+
- KEYCLOAK_HTTP_PORT=8080
51+
- KEYCLOAK_HTTPS_PORT=9443
52+
# entrypoint: /tmp/keycloak/config/docker-compose-entrypoint.sh --hostname host.docker.internal:8080
53+
volumes:
54+
- ../main-app/main-webapp/src/main/resources/keycloak/:/opt/keycloak/data/import
55+
ports:
56+
- 8082:8080
57+
- 9443:9443
58+
networks:
59+
- seedappnet
4160
volumes:
4261
esdata1:
4362
driver: local

email/email-service/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@
145145
<activation>
146146
<activeByDefault>true</activeByDefault>
147147
</activation>
148-
<dependencies>
149-
<dependency>
150-
<groupId>org.springdoc</groupId>
151-
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
152-
<version>${springdoc-openapi-ui.version}</version>
153-
<optional>true</optional>
154-
</dependency>
155-
</dependencies>
156148
<properties>
157149
<spring.profiles.active>dev</spring.profiles.active>
158150
<build.profile>dev</build.profile>

email/email-service/src/main/java/gt/mail/web/rest/HelloResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package gt.mail.web.rest;
22

3-
import gt.common.config.BaseException;
3+
//import gt.common.config.BaseException;
44
import lombok.RequiredArgsConstructor;
55
import lombok.extern.slf4j.Slf4j;
66
import org.springframework.web.bind.annotation.GetMapping;
@@ -21,9 +21,9 @@ public class HelloResource {
2121
@GetMapping("/hello")
2222
public Map<String, String> sayHello() {
2323
log.info("Received hello request");
24-
if (RANDOM.nextBoolean()) {
25-
throw new BaseException("Something");
26-
}
24+
// if (RANDOM.nextBoolean()) {
25+
// throw new BaseException("Something");
26+
// }
2727
return Map.of("hello", "world");
2828
}
2929
}

email/email-service/src/test/java/gt/mail/web/rest/EmailResourceIT.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,27 @@
1717
class EmailResourceIT {
1818

1919
@Test
20-
void sayHello2(@Autowired MockMvc mvc) throws Exception {
20+
void canSendEmail(@Autowired MockMvc mvc) throws Exception {
2121

2222
mvc.perform(
23-
post("/sendEmail")
24-
.contentType(MediaType.APPLICATION_JSON)
25-
.content(sampleEmail().getBytes()))
23+
post("/sendEmail")
24+
.contentType(MediaType.APPLICATION_JSON)
25+
.content(sampleEmail().getBytes()))
2626
.andExpect(status().isOk());
2727
}
2828

2929
String sampleEmail() {
30-
return "{\"from\":\"test@email.com\",\"subject\":\"Test\",\"content\":\"Body\",\"isHtml\":false,\"files\":[],\"to\":[\"recep@emai.com\"],\"cc\":[],\"bcc\":[]}";
30+
return """
31+
{
32+
"fromEmail":"test@email.com",
33+
"subject":"Test",
34+
"content":"Body",
35+
"isHtml":false,
36+
"files":[],
37+
"to":["recep@emai.com"]
38+
,"cc":[],
39+
"bcc":[]
40+
}
41+
""";
3142
}
3243
}

email/email-service/src/test/resources/application.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ spring:
1212
port: ${MAILHOG_PORT:1025}
1313
username:
1414
password:
15-
15+
security:
16+
oauth2:
17+
resourceserver:
18+
jwt:
19+
issuer-uri: http://localhost:${KEYCLOAK_PORT:8082}/realms/articleapp
1620
logging.level:
1721
ROOT: WARN
1822
gt: INFO

main-app/main-orm/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,15 @@
9898
<propertyFile>src/main/resources/liquibase-jpa-diff.properties</propertyFile>
9999

100100
<!-- liquibase:generateChangeLog-->
101-
<!--<propertyFile>src/main/resources/liquibase-existing-db.properties</propertyFile>-->
101+
<!-- <propertyFile>src/main/resources/liquibase-existing-db.properties</propertyFile>-->
102102

103103
</configuration>
104104
<dependencies>
105+
<dependency>
106+
<groupId>org.liquibase.ext</groupId>
107+
<artifactId>liquibase-hibernate6</artifactId>
108+
<version>${liquibase.version}</version>
109+
</dependency>
105110
<dependency>
106111
<groupId>org.springframework</groupId>
107112
<artifactId>spring-beans</artifactId>

0 commit comments

Comments
 (0)