-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor Server Authentication not working after publishing to Azure (linux) #25430
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
Comments
@drma-dev thanks for contacting us. @blowdart this is not Blazor server specific since auth happens before the Blazor application starts (this is server-side Blazor). From what I can tell, the callback is not hitting the auth endpoint and going through the catch-all route that SSB defines instead. Note that it if goes there is because no other endpoint/handler was available. |
It started after a certain time. I'm not sure if it was from a certain version of blazor or something that happened on azure. another mistake is that if you log in with email and password (without google), it cannot call the API, because it cannot recognize the user's token or authentication. |
This doesn't sound generic to me @javiercn - perhaps something with the identity server integration give the inability to call the api. regardless, @drma-dev what's in the server logs? Can you up the verbosity and try? |
@blowdart Blazor server doesn't use Identity Server (at least our templates). We only use it on Blazor WebAssembly. Blazor server apps use whatever auth mechanism you want to use for a regular Web Application, all the auth happens before the Blazor Server app starts. What is likely happening there is what I mentioned above, the auth callback endpoint is somehow not correctly configured, and it's going through the fallback route that server-side Blazor defines, but the issue is that the auth handler is not correctly configured in some way. |
OK in that case, startup.cs pleas @drma-dev |
Even using the template (with authentication option) without changing anything in the code (forgetting this google issue), it will give an error when accessing the api with [Authorize]. And it only happens in azure (linux environment), if I publish in azure (windows environment) it works normally. I believe that both errors (API and google) are related to the same thing. |
OK what template, what error? What's in the server logs? |
https://github.com/drma-dev/BlazorApp1 https://app-verusdate-beta.azurewebsites.net/ (fetch data page) I don't know how to catch errors (verbosity) in azure |
@drma-dev thanks for the repro. This turned out to be Blazor webassembly, not server-side Blazor. Moving to the blazor area |
@drma-dev just co confirm, your scenario is that you have a hosted Blazor WebAssembly application that uses individual auth (Identity + Identity Server) and you are trying to offer the option to users to authenticate using their google credentials as part of logging in with Google, and it's failing after you click login with google on the UI and tries to come back to the application? |
Yes, but this error only occurs when it is published in azure (web app - linux environment). And if you log in using the traditional method (email + password) the login works, but the APIs stop responding due to authentication failure. |
That seems like two separate issues to me:
|
No. I believe it is a limitation of the linux web app |
Not sure what you mean by this |
localhost does not have these errors. |
@javiercn is it clear now? I haven't found any place that can report azure bugs, so I'm here |
I was experiencing this issue - the "/signin-google" request was being served from index.html. The fix is to add the endpoint into the list of exclusions in In Client\wwwroot\service-worker.published.js:
|
thanks. you save my life. |
Although I am able to login, there is still an error when accessing a protected api. did you go through this @carlingkirk?
|
@drma-dev Yes - unfortunately I had to set it explicitly in
|
thanks |
Yes, worked a treat. but I'd suggest to make the string '/signin-' this way if you add multi providers which usually default to signin-google, signin-microsoft etc these will all work. |
You need to specify the issuer explicitly when deploying to App Service on LInux. services.AddAuthentication()
.AddIdentityServerJwt();
services.Configure<JwtBearerOptions>(IdentityServerJwtConstants.IdentityServerJwtBearerScheme, options =>
{
options.Authority = "https://my-service.azurewebsites.net";
}); @guardrex can we add a note to the docs? |
https://site.azurewebsites.net/
signin-google
?state=xxx
&code=yyy
&scope=email+profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile
&authuser=0
&prompt=none
Sorry, there is nothing at this address.
This error occurs after trying to log in to google in a blazor app after publishing in azure linux (the same did not happen in the windows environment).
logging in normally (user + password) works, but cannot communicate with the API.
The text was updated successfully, but these errors were encountered: