Call identity provider in code with C# / .NET Core Microsoft OIDC library

I am converting a website to .NET Core, and switching nuget for authorization to Microsoft.AspNetCore.Authentication.OpenIdConnect.
We use Azure b2c to handle login for website users.

We also use the CMS Optimizely, so I have left default authentication be and added my as a secondary one to not mess up Optimizely’s admin login, but that is (probably) not relevant to this question.

I have configured my auth scheme in startup.cs, and decorated my controllers with [Authorize].

This works, user are sent to azure to log in when needed, and I can access HttpContext.User.Claims and HttpContext.User.Identity.IsAuthenticated in the code.
Logout also works.

But I also have to implement a create account button, and change password button.

These should send the users to slightly different authority urls.

When logging in the library handles creating the authority url, with state and nonce properties and more, and if possible I would want to avoid doing that myself (I trust the library more than myself).

So how can I send the user to a authority in code (without using the [authorize] attribute)?

Startup.cs (relevant parts):

using Microsoft.IdentityModel.Protocols.OpenIdConnect;

services
    .AddAuthentication()
    .AddCookie("oidc-cookie", options =>
    {
        options.LogoutPath = "/";
        options.AccessDeniedPath = "/AccessDenied";
    })
    .AddOpenIdConnect("oidc-scheme", options =>
    {
        options.SignInScheme = "oidc-cookie";
        options.SignOutScheme = "oidc-cookie";
        options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
        options.CallbackPath = "/signin-oidc";
        options.SignedOutCallbackPath = "/signout-oidc";
        options.AccessDeniedPath = "/AccessDenied";
        options.ClientSecret = SiteSettings.AppSettings.OAuthClientSecret;
        options.UsePkce = true;
        options.Authority = "https://company.b2clogin.com/company.onmicrosoft.com/B2C_1A_signin/v2.0/";
        options.ClientId = SiteSettings.AppSettings.OAuthClientID;
        options.Scope.Clear();
        options.Scope.Add(OpenIdConnectScope.OpenId);
        options.Scope.Add(OpenIdConnectScope.OfflineAccess);
        options.Scope.Add(options.ClientId);
        options.MapInboundClaims = false;
        options.TokenValidationParameters = new TokenValidationParameters
        {
            NameClaimType = "name",
            RoleClaimType = ClaimTypes.Role
        };

        options.Events.OnRedirectToIdentityProvider = ctx =>
        {
            // Code to att ui_locales url parameter to identity provider call
        };
    });
    .AddSingleton<IAuthorizationHandler, AllowEveryoneHandler>();
    .AddSingleton<IAuthorizationHandler, AzureIdHandler>();
    .AddAuthorization(options =>
    {
        options.AddPolicy("AllowEveryonePolicy", policy =>
        {
            policy.Requirements.Add(new AllowEveryoneRequirement());
        });
        options.AddPolicy("RequireAzureIdPolicy", policy =>
        {
            policy.Requirements.Add(new AzureIdRequirement());
        });
    });

Controller code:

[Authorize(AuthenticationSchemes = "oidc-scheme", Policy = "AllowEveryonePolicy")]
public class StartPageController : BasePageController<Models.StartPage>
{
    // Controller code
}

Notes to code: /AccessDenied is defined by me. /signin-oidc and /signout-oidc are defined by the library.

Urls for signing in, creating account and changing passwords is:

https://company.b2clogin.com/company.onmicrosoft.com/B2C_1A_signin/v2.0/authorize?client_id=...&nonce=...&state=...&...   
https://company.b2clogin.com/company.onmicrosoft.com/B2C_1A_signup_signin/v2.0/authorize?client_id=...&nonce=...&state=...&...    
https://company.b2clogin.com/company.onmicrosoft.com/B2C_1A_passwordchange/v2.0/authorize?client_id=...&nonce=...&state=...&...

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật