How to pass variables from URL to spring a secure user login form?

I have an application that needs to fill out a login form with variables captured from a URL. My security configuration:

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
    .antMatchers("/", "/home").access("hasRole('USER') or hasRole('ADMIN') or hasRole('MANAGER')")
    .antMatchers("/admin/**").access("hasRole('ADMIN') or hasRole('MANAGER')")
    .and().formLogin().loginPage("/login")
    .loginProcessingUrl("/login").usernameParameter("username").passwordParameter("password")
    .and().rememberMe().rememberMeParameter("remember-me").tokenRepository(tokenRepository)
    .tokenValiditySeconds(90*24*60*60).and().csrf().and().exceptionHandling().accessDeniedPage("/Access_Denied");
}

And when I tried to access the application with the URL: "app.com/home" I get app.com/loginand, of course, the form is empty. So, I need the user to get their identifier passed from this URL: app.com/home?user=test1and submit this user to my user login form:

But at the moment I can’t get it - how can I get this path variable in the code, and where can I get it.

+4
source share

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


All Articles