Spring Security without using a database using a database

I want to implement Spring Security (authentication and authorization). I’m Google about this and any MKYoung Spring Security example , I just want to distinguish URLs between an authenticated user and an anonymous user, I don’t want to use role-based authorization.

Any users who are registered and logged in, I want to allow them for all URLs and for anonymous users, I want them to be on the login and registration page. Thanks

+4
source share
2 answers

You tried to do this in the wmw w760 security configuration file:

<security:http auto-config="true" use-expressions="true"> <security:intercept-url pattern="/login" access="permitAll" /> <security:intercept-url pattern="/registration" access="permitAll" /> <security:intercept-url pattern="/**" access="isAuthenticated()" /> ... </security:http> 
+4
source

you can achieve this using the query:

 authorities-by-username-query="select username, 'default' from users where username=?" 
+1
source

Source: https://habr.com/ru/post/1486464/


All Articles