Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0296eed6bd | ||
|
|
a19bed652c | ||
|
|
45d21154cc | ||
|
|
46a618daea | ||
|
|
a1cff78f0c | ||
|
|
94dd6355b4 | ||
| f2fead959d | |||
|
|
be2a470d01 | ||
|
|
643cb9da78 | ||
|
|
d2e154b263 | ||
|
|
406355be95 |
@@ -6,7 +6,7 @@
|
||||
<httpHeaders>
|
||||
<property>
|
||||
<name>Authorization</name>
|
||||
<value>token {access_token}</value>
|
||||
<value>token ${env.MAVEN_TOKEN}</value>
|
||||
</property>
|
||||
</httpHeaders>
|
||||
</configuration>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"branches": ["master"],
|
||||
"tagFormat": "${version}",
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
|
||||
35
CHANGELOG.md
35
CHANGELOG.md
@@ -1,3 +1,38 @@
|
||||
## [1.2.2](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/compare/1.2.1...1.2.2) (2025-09-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix requestMatcher for actuator ([a19bed6](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/commit/a19bed652cc87cf02e45fc0c14e2082eaa176830))
|
||||
|
||||
## [1.2.1](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/compare/1.2.0...1.2.1) (2025-09-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update bean init ([46a618d](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/commit/46a618daea7637c565240e468829294860cc6478))
|
||||
|
||||
# [1.2.0](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/compare/v1.1.0...1.2.0) (2025-09-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* refactor way to get CallerId ([94dd635](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/commit/94dd6355b40e69ef6863a225bbe60f9f8a780047))
|
||||
|
||||
# [1.1.0](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/compare/v1.0.1...v1.1.0) (2025-09-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update settings.xml ([643cb9d](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/commit/643cb9da78e41bcc0de7f08a94fe3e27efcc98be))
|
||||
|
||||
## [1.0.1](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/compare/v1.0.0...v1.0.1) (2025-09-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* force a patch release ([406355b](https://git.tools.ldpt.fr/lucasdpt/spring-keycloak-starter/commit/406355be95277e35781c19ab312f60e413bc97af))
|
||||
|
||||
# 1.0.0 (2025-09-21)
|
||||
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>fr.lucasdupont</groupId>
|
||||
<artifactId>spring-keycloak-starter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.2.2</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
|
||||
@@ -1,28 +1,14 @@
|
||||
package fr.lucasdupont.security;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.oauth2.jwt.Jwt;
|
||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken;
|
||||
import org.springframework.web.bind.support.WebDataBinderFactory;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
public class CallerIdArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter parameter) {
|
||||
return CallerId.class.isAssignableFrom(parameter.getParameterType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter parameter,
|
||||
ModelAndViewContainer mavContainer,
|
||||
NativeWebRequest webRequest,
|
||||
WebDataBinderFactory binderFactory) throws IllegalAccessException {
|
||||
public class CallerIdResolver {
|
||||
|
||||
public CallerId get() throws IllegalAccessException {
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (!(auth instanceof JwtAuthenticationToken jwtAuth)) {
|
||||
throw new IllegalAccessException("Authentication is not of type JwtAuthenticationToken");
|
||||
@@ -44,4 +30,5 @@ public class CallerIdArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
return new CallerId(sub, CallerId.Type.USER);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,10 +9,6 @@ import org.springframework.security.config.annotation.web.configurers.AbstractHt
|
||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AutoConfiguration
|
||||
@ConditionalOnClass(HttpSecurity.class)
|
||||
@@ -30,7 +26,7 @@ public class KeycloakAutoConfiguration {
|
||||
http
|
||||
.csrf(AbstractHttpConfigurer::disable)
|
||||
.authorizeHttpRequests(registry -> registry
|
||||
.requestMatchers("/actuator/health", "/actuator/info").permitAll()
|
||||
.requestMatchers("/actuator/health", "/actuator/info", "/actuator/health/*", "/actuator/info/*").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.oauth2ResourceServer(oauth2 -> oauth2
|
||||
@@ -48,18 +44,8 @@ public class KeycloakAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer callerIdArgumentResolverConfigurer(CallerIdArgumentResolver resolver) {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
|
||||
resolvers.add(resolver);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CallerIdArgumentResolver callerIdArgumentResolver() {
|
||||
return new CallerIdArgumentResolver();
|
||||
public CallerIdResolver callerIdResolver() {
|
||||
return new CallerIdResolver();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user