Ich habe eine 2 Spring-Boot-Anwendungen mit einer Anwendung läuft als "Gateway" zu Authentifizierung und Routing (mit Zuul Proxy) und die andere als eine UI ("/ admin") hinter dem Gateway.Zurück zu/Login auf zuul Proxy-URL, wenn nicht authentifiziert
Wenn ich auf "/ login" (oder einen anderen Endpunkt auf dem Gateway selbst) klicke, werde ich zur Seite "login.html" geleitet, dann kann ich meine Zugangsdaten eingeben und mich authentifizieren. Danach kann ich problemlos auf "/ admin" zugreifen.
Mein Problem ist, wenn ich "/ admin" treffe, bevor authentifiziert wird, werde ich nicht zu "/login.html" weitergeleitet, sondern bekomme nur das "basic auth" Popup und frage nach Anmeldeinformationen, was ich nicht tue Ich will nicht.
Hier ist meine Konfiguration auf dem Gateway-Server.
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.maximumSessions(1)
.expiredUrl("/login")
.maxSessionsPreventsLogin(false)
.sessionRegistry(sessionRegistry())
.and()
.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
.invalidSessionUrl("/login");
http.addFilterBefore(new ApiKeyAuthenticationFilter(macSigner()), BasicAuthenticationFilter.class);
http.httpBasic().and()
.authorizeRequests()
.antMatchers("/", "/home", "/index","/support.html", "/about.html","/features.html","/fonts/**","/ws/**",
"/contacts.html","/img/**","/logos/**","/docs/**").permitAll()
.antMatchers("/admin**").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.csrf().ignoringAntMatchers("/resource/api/**","/api/**").csrfTokenRepository(csrfTokenRepository())
.and()
.addFilterAfter(csrfHeaderFilter(), SessionManagementFilter.class)
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login")
.permitAll();
}
und hier ist die Config auf meinem Admin-Server
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().and().authorizeRequests().anyRequest().authenticated();
http.csrf().disable();
}
Kann jemand mir einen Rat geben, wo Sie zu graben?
Dieses danken Ihnen gearbeitet! –