BAEL-5252-new-spring-boot-keycloak-2-module
This commit is contained in:
parent
8f07f96470
commit
017dfa3d6d
|
@ -45,6 +45,7 @@
|
||||||
<!-- <module>spring-boot-gradle</module> --> <!-- Not a maven project -->
|
<!-- <module>spring-boot-gradle</module> --> <!-- Not a maven project -->
|
||||||
<module>spring-boot-jasypt</module>
|
<module>spring-boot-jasypt</module>
|
||||||
<module>spring-boot-keycloak</module>
|
<module>spring-boot-keycloak</module>
|
||||||
|
<module>spring-boot-keycloak-2</module>
|
||||||
<module>spring-boot-libraries</module>
|
<module>spring-boot-libraries</module>
|
||||||
<module>spring-boot-libraries-2</module>
|
<module>spring-boot-libraries-2</module>
|
||||||
<module>spring-boot-libraries-comparison</module>
|
<module>spring-boot-libraries-comparison</module>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
## Spring Boot Keycloak
|
||||||
|
|
||||||
|
This module contains articles about Keycloak in Spring Boot projects.
|
||||||
|
|
||||||
|
## Relevant articles:
|
||||||
|
- [Disabling Keycloak Security in Spring Boot](https://www.baeldung.com/spring-keycloak-security-disable)
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.baeldung.keycloak</groupId>
|
||||||
|
<artifactId>spring-boot-keycloak-2</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<name>spring-boot-keycloak-2</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<description>This is a simple application demonstrating integration between Keycloak and Spring Boot.</description>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-boot-2</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../parent-boot-2</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<keycloak-adapter-bom.version>15.0.2</keycloak-adapter-bom.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.bom</groupId>
|
||||||
|
<artifactId>keycloak-adapter-bom</artifactId>
|
||||||
|
<version>${keycloak-adapter-bom.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||||
|
</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -1,28 +1,25 @@
|
||||||
package com.baeldung.disablingkeycloak;
|
package com.baeldung.disablingkeycloak;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = App.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(classes = App.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@ActiveProfiles("disablingkeycloak")
|
@ActiveProfiles("disablingkeycloak")
|
||||||
public class DisablingKeycloakIntegrationTest {
|
class DisablingKeycloakIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TestRestTemplate restTemplate;
|
private TestRestTemplate restTemplate;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenUnauthenticated_whenGettingUser_shouldReturnUser() {
|
void givenUnauthenticated_whenGettingUser_shouldReturnUser() {
|
||||||
ResponseEntity<User> responseEntity = restTemplate.getForEntity("/users/1", User.class);
|
ResponseEntity<User> responseEntity = restTemplate.getForEntity("/users/1", User.class);
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_OK, responseEntity.getStatusCodeValue());
|
assertEquals(HttpStatus.SC_OK, responseEntity.getStatusCodeValue());
|
|
@ -10,4 +10,3 @@ This module contains articles about Keycloak in Spring Boot projects.
|
||||||
- [Customizing Themes for Keycloak](https://www.baeldung.com/spring-keycloak-custom-themes)
|
- [Customizing Themes for Keycloak](https://www.baeldung.com/spring-keycloak-custom-themes)
|
||||||
- [Securing SOAP Web Services With Keycloak](https://www.baeldung.com/soap-keycloak)
|
- [Securing SOAP Web Services With Keycloak](https://www.baeldung.com/soap-keycloak)
|
||||||
- [Get Keycloak User ID in Spring](https://www.baeldung.com/spring-keycloak-get-user-id)
|
- [Get Keycloak User ID in Spring](https://www.baeldung.com/spring-keycloak-get-user-id)
|
||||||
- [Disabling Keycloak Security in Spring Boot](https://www.baeldung.com/spring-keycloak-security-disable)
|
|
||||||
|
|
Loading…
Reference in New Issue