Customizing login experience in Spring MVC web apps
ฝัง
- เผยแพร่เมื่อ 2 ก.ค. 2024
- Part 4 of multipart series where simple java spring mvc web app is secured by spring security framework. Authentication is also enabled by google and github social login oath2/oidc providers and users saved to relational database.
App is deployed to various cloud providers.
In part 4, we'll replace Spring security default login form with our custom login form and customize user's login and logout experience
Railway.app:
tinyurl.com/railway-kanezi
Github repo:
github.com/kanezi/spring-soci...
00:00 - intro
00:18 - goals of this session
01:05 - prerequisite
01:44 - current application state
02:30 - public home page
03:16 - request caching
03:48 - app skeleton
08:46 - home page
11:44 - resources filter chain
15:56 - main menu
20:25 - user controller
21:41 - user page
23:04 - accessing authenticated user
28:30 - login page
34:16 - logout
38:41 - login & logout redirections
42:47 - testing controllers
44:47 - test configuration
48:19 - testing oauth2 and oidc
53:11 - outro
Awesome☺clear and precise
U r the best!
Hey, i am not sure if you are reading comments, but this was great and it helped a lot. I am struggling with one thing though and it is assigning roles to user, like (admin, user, etc.) Is there any chance you can do one tutorial about that and PreAuthorize
you are probably in a hurry, I'm not sure you have the time to wait for my video :) what kind of app and where are you storing users? If you have public service you'd usually assign some default role when user signs in and privileged role for paying customer and protect resources based on that. If you have an enterprise app and store your users in a database for example, you'd need to have form in your app for managing users and roles that admin's have rights to access. First admin can be created manually by someone who has dba access to database.
@kanezi haha it's fine I am just a junior at a company, we have internal app that I am currently working on, my mentor will go over spring security with us soon, I just wanted to prepare part of it but since spring changed to FilterChain recently I don't have enough experience with it, thank you for the video regardless, keep it on :)
@kanezi we have an internal app that has 2 roles, admin and employee. Admin can access users info and can manage some other parts, its stored in Postgresql, that's kinda the gist of it.
I was on both sides, had multiple mentors, and right this week I'm leading two new guys in and I can tell you
a) no one expects you know everything, if you did, you wouldn't be a junior
b) ask questions, it would show me you are interested, and sometimes people are so long on project, things that might be new to you might be second nature to them and they wouldn't even bother to explain
c) never in my career have I asked a question and not gotten an answer, people actually enjoy to answer, in a way it shows you have high opinion of them if you seek their advice
good luck
@kanezi huh I guess I forgot to answer. Yeah, people I am currently working with are great, and I am genuinely getting better every single day, projects are fun and I feel appreciated even though I am just a junior, I guess I struck a bulls eye with them or maybe it is just a lack of experience talking. I worked as a mechanical engineer for 2 years and making a switch was definitely the best decision I could have made.
Could you please explain how to do the same app but with some external frontend on another host?
could you provide more details? In the near future there will be videos explaining how to connect SPA (single page app) app, like angular, to spring backend api
@@kanezi If coming videos about SPA will include social login then this is it.
@@kanezi Would love a video with Angular!
you can have a look at blocking vs reactive video:
th-cam.com/video/4GbwKdNFzvs/w-d-xo.html that uses Angular to talk to java backend and where I explain basics of angular. More will come
@@kanezi probably this must will send througth REST like a contentType: text/html
Man this is just what I wanted to see!!! I was stuck at this for a week. Thanks for clearing out everything 🫡🫡
Glad it helped! Everyone gets stuck and frustrated with spring!