how to implement a authentication with spring boot security? -


i using spring boot. want post username , password params login, , if login success return token. after, use token judge login status. here security configure code. don't konw write login authentication logic code.

securityconfig.java

@configuration @enablewebsecurity public class securityconfig extends websecurityconfigureradapter {         @override      protected void configure(httpsecurity http) throws exception {          http.authorizerequests()                 .anyrequest()                 .fullyauthenticated()                 .and()                 .formlogin()                 .loginpage("/user/unlogin")                 .permitall();       }       @override      public void configure(websecurity web) throws exception {          web.ignoring().antmatchers("/user/login")                 .antmatchers("/user/logout")                 .antmatchers("/user/register");       } } 

==========================

thank !

there's more 1 way spring. there happy path (probably) spring boot, , seem have started on it. note though, if want boot provide default behaviour, don't use @enablewebsecurity (as advised in user guide). web-secure sample has example can follow.

if use formlogin() default login url /login (not /user/login), should able post username , password endpoint authenticate. don't add /login unsecured paths using web.ignoring() or spring security never process it. when post /login jsessionid cookie. that's authentication token, , expires when session expires in server (30min default, configurable). include in future requests secure resources - http clients (like browser does).


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -