ajout api version
This commit is contained in:
@@ -36,3 +36,7 @@ dependencies {
|
|||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
springBoot {
|
||||||
|
buildInfo()
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package fr.bonsai.api.adapter.in.web;
|
||||||
|
|
||||||
|
import org.springframework.boot.info.BuildProperties;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/version")
|
||||||
|
public class VersionController {
|
||||||
|
|
||||||
|
private final BuildProperties buildProperties;
|
||||||
|
|
||||||
|
public VersionController(BuildProperties buildProperties) {
|
||||||
|
this.buildProperties = buildProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public VersionResponse get() {
|
||||||
|
return new VersionResponse(buildProperties.getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
public record VersionResponse(String version) {}
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ public class SecurityConfig {
|
|||||||
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||||
|
.requestMatchers(HttpMethod.GET, "/version").permitAll()
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer(oauth2 -> oauth2
|
.oauth2ResourceServer(oauth2 -> oauth2
|
||||||
|
|||||||
Reference in New Issue
Block a user