Тёмный

Authentication with Spring Boot, Angular and Keycloak (with roles) 

lup @join-it
Подписаться 192
Просмотров 10 тыс.
50% 1

In this minimal example I explain how to setup authentication with Spring Boot, Angular and Keylcoak.
Github: github.com/lel...

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 15   
@mikoajtelus5458
@mikoajtelus5458 Год назад
After weeks of trying to configure it, thanks to your video, I finally succeeded. Thank you so much!
@join-it
@join-it Год назад
You are welcome :)
@siriusmarz512
@siriusmarz512 Год назад
thank you this has really helped me a lot
@EdarKEA
@EdarKEA Год назад
Gracias bro! Eres un pro!
@join-it
@join-it Год назад
Gracias! :)
@rutulshah2007
@rutulshah2007 7 месяцев назад
Can you guide in your code how to allow only certain API URLs based on a specific roles. Something like allow getDetails API only if it has Admin role. How to add this in security config ?
@join-it
@join-it 7 месяцев назад
Sure, you can add this with @hasAuthority at your Controller-Method (if @EnableMethodSecurity is set) or with .hasRole("ADMIN") in the requestMatchers in SecurityFilterChain. Then you need to add the Role in Keycloak to the user and map the role to ROLE_ADMIN in the KeycloakRoleConverter
@wulfhound2859
@wulfhound2859 Год назад
well made, not easy to do. How would you add a url that does not need authentication, say for instance you have a contact page, how would you add this? And disabling csrf is also a security concern, how would you tackle this?
@join-it
@join-it Год назад
Hello Wulf, Thank you :) Allowing specific endpoints for everyone is just a line of code using Spring Security. Either add an request and set it to permitAll() or use the @EnableGlobalMethodSecurity in your configuration and add @PermitAll to the endpoint. r -> r.requestMathers("/public/**", "/api/greeting" ).permitAll().anyRequest().authenticated() this permits the named routes for everyone, so no token is needed. Any other requests needs a valid authentication token. Also as in this example it is only using JWT and the backend is stateless, disabling csrf is not a security concern. If you would have still state and jsession in your application, then you would not to enable csrf and ignore the api routes. For SPA with JWT cors is important.
@SabrineZaddem-t8g
@SabrineZaddem-t8g 7 месяцев назад
thank you for this amazing video can u do a video with 24.0.1 keycloak version i really need it thanks
@join-it
@join-it 7 месяцев назад
Hello, as far as it looks it hasn't changed much. Here is a short official example: github.com/keycloak/keycloak-quickstarts/tree/latest/spring/rest-authz-resource-server
@thejashwinisridhar3043
@thejashwinisridhar3043 8 месяцев назад
Hi , I am receiving org.springframework.security.oauth2.jwt.JwtDecoderInitializationException: Failed to lazily resolve the supplied JwtDecoder instance with Caused by: java.lang.IllegalArgumentException: Unable to resolve the Configuration with the provided Issuer.Can you please help?
@join-it
@join-it 7 месяцев назад
Hey, maybe you are on a newer Spring Boot Version and they changed something. When I have time I will try to reproduce the error and post the solution here. Have you tried to work with a lesser version yet?
@thejashwinisridhar3043
@thejashwinisridhar3043 7 месяцев назад
@@join-it Thanks for the reply, looks like proxy issue as it works in my local. Faced this issue while connecting to my organisation's server
Далее
Keycloak и Spring Security
37:37
Просмотров 14 тыс.
How to integrate Keycloak with Angular 10?
18:04
Просмотров 37 тыс.
НИКИТА ПОДСТАВИЛ ДЖОНИ 😡
01:00
Просмотров 116 тыс.
Fullstack OAuth2 - Angular, Spring Boot & Keycloak
26:35
Spring Security Oauth2 Tutorial with Keycloak - Part 1
22:20
Spring Security - Refresh token
26:20
Просмотров 34 тыс.