I try to integrate keycloak on my web app, which is using spring boot but i have an issue that I don't know exactly how to deal with.
I have here the application.properties
keycloak.auth-server-url=http://localhost:8080/auth
keycloak.realm=SpringBoot
keycloak.resource=GCE
keycloak.public-client=true
keycloak.ssl-required=external
keycloak.security-constraints[0].authRoles[0]=user
keycloak.security-constraints[0].securityCollections[0].patterns[0]=/start
server.port=8180
spring.session.store-type=none
Here is my controller, and where I start the app
@SpringBootApplication
public class GCEApplication {
public static void main(String[] args) {
SpringApplication.run(GCEFinalApplication.class, args);
}
}
@Controller
class AppController {
@GetMapping(path = "/start")
public String start(){
System.out.println(1);
return "start";
}
@GetMapping(path = "/logout")
public String logout(HttpServletRequest request) {
try {
request.logout();
} catch (Exception e) {
System.out.println(e.getStackTrace());
}
HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
}
return "/";
}
}
This is my index page, and it is in resources/static
<!DOCTYPE html>
<html xmlns="http://ift.tt/lH0Osb"
xmlns:th="http://ift.tt/wfNV60"
xmlns:sec="http://ift.tt/1vQCupq"
xmlns:layout="http://ift.tt/1nWSSl4">
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<a href="/start">Start</a>
</body>
</html>
And the start page is .ftl template
<#import "/spring.ftl" as spring>
<html>
<h1>My products</h1>
<br>
<a href="/logout">Logout</a>
</html>
When I try to access the start page it gave me 403 error. It works to connect to Keycloak, and the session starts but I think the redirect is not ok
Aucun commentaire:
Enregistrer un commentaire