Skip to content

spring boot app Security with keycloak using OpenId using JWT Token and thymeleaf template for front test

Notifications You must be signed in to change notification settings

mohalaoui/keycloak_spring_boot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keycloak spring-boot simple

template

  • thymeleaf starter
  • spring-boot-starter-thymeleaf
  • path : /src/main/resources/templates

security

Spring security


	  http
            .authorizeRequests()
            .antMatchers("/products").hasRole("user")
            //.antMatchers("/products/*").hasRole("admin")
            .anyRequest().permitAll();
      
      http.csrf().disable();
  • use HttpSecurity to set our authorization strategy
  • we can use role annotations instead

keycloak

  1. create a realm
  2. create a client
  3. create a role(s)
  4. create a user
  5. add role(s) to user

keycloak spring config

application.properties :


keycloak.auth-server-url=http://your_keyclok_url:port/auth
keycloak.realm=springDemo 
keycloak.resource=product-app # client name
keycloak.public-client=true

keycloak.principal-attribute=preferred_username # default claim send in JWT, you can create a custom one via user attributes

spring.main.allow-bean-definition-overriding=true

About

spring boot app Security with keycloak using OpenId using JWT Token and thymeleaf template for front test

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published