Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor oidc doesn't return meaningfull error messages #55791

Open
1 task done
Mohamed1984 opened this issue May 19, 2024 · 2 comments
Open
1 task done

Blazor oidc doesn't return meaningfull error messages #55791

Mohamed1984 opened this issue May 19, 2024 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-oidc
Milestone

Comments

@Mohamed1984
Copy link

Mohamed1984 commented May 19, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I use blazor with openid connect authentication.

I follow microsoft documentation and create an authentication page:

@page "/authentication/{action}"

<RemoteAuthenticatorView Action="@Action">
</RemoteAuthenticatorView>

@code {
[Parameter]
[EditorRequired]
public string? Action { get; set; }
}

If any error happens the authentication page displays general message without details:

"There was an error signing in."

I assume, there should be a way to get error details.

Namely, there should be a way to get error and error_description of oidc spec.

Expected Behavior

The authentication page should display error and error_description fields

Steps To Reproduce

Any blazor app that utilizes oidc authentication and utilize the authentication page will show the same behaviour.

Exceptions (if any)

No response

.NET Version

No response

Anything else?

I digged into asp.net core source to find the problem source.

The problem is in this file:

https://github.com/dotnet/aspnetcore/blob/main/src/Components/WebAssembly/WebAssembly.Authentication/src/Interop/AuthenticationService.ts

Specifically in the completeSignIn function (line 258):

async completeSignIn(url: string) {
        this.trace('completeSignIn', url);
        const requiresLogin = await this.loginRequired(url);
        const stateExists = await this.stateExists(url);
        try {
            const user = await this._userManager.signinCallback(url);
            if (window.self !== window.top) {
                return this.operationCompleted();
            } else {
                this.trace('completeSignIn-result', user);
                return this.success(user && user.state);
            }
        } catch (error) {
            if (requiresLogin || window.self !== window.top || !stateExists) {
                return this.operationCompleted();
            }

            return this.error('There was an error signing in.');
        }
    }

You should just adjust the line "return this.error('There was an error signing in.');" to return error details

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label May 19, 2024
@mkArtakMSFT
Copy link
Member

Thanks for contacting us.
Can you please share more details about what specific error you're trying to see?

Please note, if you are simply curious to see what the actual error is, you can read that information from the querystring from the page you're on.

@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label May 20, 2024
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone May 20, 2024
@Mohamed1984
Copy link
Author

Thanks for contacting us. Can you please share more details about what specific error you're trying to see?

Please note, if you are simply curious to see what the actual error is, you can read that information from the querystring from the page you're on.

OpenIdConnect protocol provides error and error_description fields for two endpoints:

  • The authorize endpoint that sends the error details using HTTP redirect
  • The token end point that returns the error details in HTTP response body

The error details can be inferred from query string in the first case only.

I think it is better that the RemoteAuthenticatorView provides a way to report these errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-oidc
Projects
None yet
Development

No branches or pull requests

3 participants
@Mohamed1984 @mkArtakMSFT and others