Cannot navigate to secured View when not logged for OAuth2
See original GitHub issueDescription of the bug
When using RouterLink and Anchor to a secured @Route with @PermitAll an error page is displayed when not logged in.
Could not navigate to ‘<page>’ Available routes:
Expected behavior
A login page should be show. Azure call it user flow: https://docs.microsoft.com/en-us/azure/active-directory-b2c/user-flow-overview.
Adding router-ignore makes it work. I have added router-ignore to the /logout link which is not a Vaadin route.
Minimal reproducible example
It is the same behavior for com.azure.spring:spring-cloud-azure-starter-active-directory-b2c:4.3.0 and org.springframework.boot:spring-boot-starter-oauth2-client:2.6.7. For azure b2c the config is:
@EnableWebSecurity
public class SecurityConfig extends VaadinWebSecurityConfigurerAdapter {
private final AadB2cOidcLoginConfigurer configurer;
public SecurityConfig(AadB2cOidcLoginConfigurer configurer) {
this.configurer = configurer;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http.apply(configurer);
}
}
@Route("vaadin-hello")
@PermitAll()
public class VaadinHelloView extends VerticalLayout {
public VaadinHelloView() {
add(new H1("Hello from VAADIN"));
Versions
Vaadin: 23.2.0.alpha3 Flow: 23.2.0.alpha2 Java: JetBrains s.r.o. 17.0.2 OS: amd64 Windows 10 10.0 Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Live reload: Java active (HotswapAgent): Front end active IntelliJ Tomcat
Issue Analytics
- State:
- Created a year ago
- Comments:41 (10 by maintainers)
Top GitHub Comments
This is to be expected - see https://stackoverflow.com/a/58199008/1662997
So if you take this app and tell Vaadin about where the login view is, using
setLoginView(http, "/oauth2/authorization/google");
then it will redirect to the login view also when navigating