question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot navigate to secured View when not logged for OAuth2

See original GitHub issue

Description 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:closed
  • Created a year ago
  • Comments:41 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
knoobiecommented, Oct 5, 2022

This is to be expected - see https://stackoverflow.com/a/58199008/1662997

1reaction
Artur-commented, Sep 14, 2022

If I modify that project just a little bit to add support for oauth2 authentication (I’m attaching also this project: secured-app-oauth2.zip

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Security 5 - OAuth2 Login - Baeldung
Learn how to authenticate users with Facebook, Google or other credentials using OAuth2 in Spring Security 5.
Read more >
Using OAuth 2.0 for Web Server Applications | Authorization
Note that you must specify a valid redirect URI for the provided client_id . $client->setRedirectUri('https://oauth2 ...
Read more >
Possible Errors - OAuth 2.0 Simplified
If the client ID is not recognized, the authorization server will not redirect the user. Instead, it may display a message describing the ......
Read more >
Using Spring Security 5 to integrate with OAuth 2-secured ...
Running the app as currently configured is showing the basic authentication login page and not the expected 'Log in with OAuth 2.0' page....
Read more >
Spring Security redirect to previous page after successful login
isCommitted()) { System.out.println("Can't redirect"); return; } redirectStrategy. ... This means that redirects to secure pages will not work as intended ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found