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

ConfigureApplicationCookie does not work with AddDefaultIdentity #5828

Closed
wutever0 opened this issue Oct 18, 2018 · 10 comments · Fixed by #9529
Closed

ConfigureApplicationCookie does not work with AddDefaultIdentity #5828

wutever0 opened this issue Oct 18, 2018 · 10 comments · Fixed by #9529
Assignees
Labels
area-identity Includes: Identity and providers Done This issue has been fixed feature-identity-ui

Comments

@wutever0
Copy link

Using ConfigureApplicationCookie to change the LoginPath only works with AddIdentity but not with AddDefaultIdentity, even after adding the configuration after AddDefaultIdentity as per #1414 .

            services.AddDefaultIdentity<IdentityUser>(); //Redirects to Account/Login
            //services.AddIdentity<IdentityUser, IdentityRole>(); //Redirects to Account/LoginRegister

            services.Configure<IdentityOptions>(options =>
            {
                // Password settings.
                options.Password.RequireDigit = false;
                options.Password.RequireLowercase = false;
                
                .....

                // User settings.
                options.User.AllowedUserNameCharacters =
                "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
                options.User.RequireUniqueEmail = false;
            });

            services.ConfigureApplicationCookie(options =>
            {
                options.LoginPath = $"/Identity/Account/LoginRegister";
            });
@wutever0 wutever0 changed the title ConfigureApplicationCookie does not work with AddIdentity ConfigureApplicationCookie does not work with AddDefaultIdentity Oct 18, 2018
@wutever0
Copy link
Author

wutever0 commented Oct 18, 2018

This seems to be specifically an issue with AddDefaultUI (which is also called in AddDefaultIdentity).
When I use the following:

            services.AddIdentity<IdentityUser, IdentityRole>()
                  .AddDefaultTokenProviders()
                  .AddDefaultUI();

I am again unable to redirect to my custom login page. This is a bit confusing because as far as I understand adding a default UI should not be interfering with cookie settings or am I wrong?

Would welcome any help or suggestions I've spent several days now trying to do this the right way.

Note: IdentityDefaultUIConfigureOptions has a PostConfigure that seems to set this. Is this where things are being messed up?

@AndrewTriesToCode
Copy link
Contributor

I'm noticing this same issue. This breaks certain multi tenant scenarios in my use case.

@blowdart
Copy link
Contributor

@javiercn does this fall under your scaffolding work?

@javiercn
Copy link
Member

I think the PostConfigure is the one causing this, you can write services.PostConfigure<CookieAuthenticationOptions>(IdentityDefaults.ApplicationCookie, o => ...) to change the paths.

@blowdart
Copy link
Contributor

@Eilon Who is supporting Identity UI and scaffolding now? No-one seems to want it.

@Eilon
Copy link
Member

Eilon commented Oct 25, 2018

@mkArtakMSFT is working in the answer to that question.

@aspnet-hello aspnet-hello transferred this issue from aspnet/Identity Dec 18, 2018
@aspnet-hello aspnet-hello added this to the 3.0.0 milestone Dec 18, 2018
@aspnet-hello aspnet-hello added the area-identity Includes: Identity and providers label Dec 18, 2018
@javiercn
Copy link
Member

Closing this issue as the question has been answered and there's no more action to be taken here. See the answer above.

Thanks!

@AndrewTriesToCode
Copy link
Contributor

@javiercn

Just to be clear, when you say "there will be no action to fix this" do you mean no change will be made or that it is slated for 3.0?

@javiercn
Copy link
Member

From what I understand yes. Adding @HaoK who made the suggestion to make this postconfigure in the first place to see if he wants to reconsider.

@HaoK
Copy link
Member

HaoK commented Mar 14, 2019

Seems simple enough to just move the cookie options settings into the normal configure.

@HaoK HaoK reopened this Mar 14, 2019
@HaoK HaoK modified the milestones: 3.0.0, 3.0.0-preview4 Mar 14, 2019
@HaoK HaoK self-assigned this Mar 14, 2019
@HaoK HaoK modified the milestones: 3.0.0-preview4, 3.0.0-preview5 Apr 2, 2019
@HaoK HaoK added the Done This issue has been fixed label Apr 26, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-identity Includes: Identity and providers Done This issue has been fixed feature-identity-ui
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants