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

404 problem #46

Open
FixRM opened this issue Apr 18, 2023 · 1 comment
Open

404 problem #46

FixRM opened this issue Apr 18, 2023 · 1 comment

Comments

@FixRM
Copy link

FixRM commented Apr 18, 2023

Hello! Sorry for asking stupid things, but help will be really appreciated. I'm trying to follow your blog post. The following code works like a charm with Microsoft.AspNetCore.Authentication.OpenIdConnect:

            services
                .AddAuthentication(cfg =>
                {
                    cfg.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    cfg.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
                })
                .AddCookie()
                .AddOpenIdConnect(cfg =>
                {
                    cfg.Authority = "https://myoauthserver/";
                    cfg.ClientId = "hangfire";
                    cfg.ResponseType = "code";

                    cfg.Scope.Clear();
                    cfg.Scope.Add("openid");
                    cfg.Scope.Add("profile");
                });

but similar code don't with Microsoft.Owin.Security.OpenIdConnect:

            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);           

            app.UseCookieAuthentication(new CookieAuthenticationOptions {  });

            app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
            {   
                Authority = "https://myoauthserver/",
                ClientId = "hangfire",
                ResponseType = OpenIdConnectResponseType.Code,
                Scope = OpenIdConnectScope.OpenIdProfile
            });

At first, it doesn't pass redirect_url if it is not set explicitly. But if I set it to something like RedirectUri = "http://localhost:9001/signin-oidc" or just RedirectUri = "http://localhost:9001/" myself, redirect works but I got 404 error for / or /signin-oidc endpoint. Am I doing something wrong? I'm using latest version of Microsoft.Owin.Security.OpenIdConnect and unfortunately I stuck with Framework.

@FixRM
Copy link
Author

FixRM commented Apr 19, 2023

In case if somebody struggle with the same problem: try too add RedeemCode = true to OpenIdConnectAuthenticationOptions. It should work similar to Core version.

The only problem that left is the need to explicitly set RedirectUri parameter (

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant