Spring boot security x-auth-token not found in header -
i have spring boot application having rest services secured spring security. redis used storing sessions. have deployed application in glassfish 4.1.2. when trying login using basic auth, x-auth-token
not returned in response header. issue ?
below configuration classes:
applicationsecurityconfig
@configuration @enablewebsecurity public class applicationsecurityconfig extends websecurityconfigureradapter { @autowired private customauthenticationprovider customauthenticationprovider; @autowired private customauthenticationdetailssource source; @autowired private httplogoutsuccesshandler logoutsuccesshandler; @autowired private authenticationentrypoint authenticationentrypoint; @bean public httpsessionstrategy httpsessionstrategy() { return new headerhttpsessionstrategy(); } @autowired public void configureglobal(authenticationmanagerbuilder auth) throws exception { auth.authenticationprovider(customauthenticationprovider); } @override protected void configure(httpsecurity http) throws exception { http .authorizerequests() .antmatchers("/crr/**").access("hasrole('crr')") .anyrequest().authenticated() .and() .requestcache() .requestcache(new nullrequestcache()) .and() .logout() .logouturl("/logout") .logoutsuccesshandler(logoutsuccesshandler) .and() .httpbasic().authenticationdetailssource(source).authenticationentrypoint(authenticationentrypoint); http.exceptionhandling().authenticationentrypoint(authenticationentrypoint); http.csrf().disable(); } }
corscustomfilter
@component @order(ordered.highest_precedence) public class corscustomfilter implements filter { public void dofilter(servletrequest servletrequest, servletresponse servletresponse, filterchain chain) throws ioexception, servletexception { httpservletresponse response = (httpservletresponse) servletresponse; response.setheader("access-control-allow-origin", "*"); response.setheader("access-control-allow-methods", "post, get"); response.setheader("access-control-max-age", "3600"); response.setheader("access-control-allow-headers", "x-requested-with,content-type, authorization"); chain.dofilter(servletrequest, servletresponse); } public void init(filterconfig filterconfig) { } public void destroy() { } }
note: when deploy application in tomcat,x-auth-token
generated in response header.
Comments
Post a Comment