ASP. NET OAuth Microsoft Single Tenant login - PullRequest
0 голосов
/ 24 марта 2020

Я создаю портал Intr anet и хочу создать логин, используя учетные записи Azure AD компании. Я установил Azure App Authentication и установил его для одного арендатора, и загрузил пример проекта из Azure.

Моя проблема в том, что он не применяет одного арендатора и не разрешает учетные записи Microsoft из других организаций.

Вот мой код конфигурации в Startup.cs

public void Configuration(IAppBuilder app)
    {
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
        app.UseCookieAuthentication(new CookieAuthenticationOptions());
        app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {

                ClientId = clientId,
                Authority = authority,
                RedirectUri = redirectUri,
                PostLogoutRedirectUri = redirectUri,
                Scope = OpenIdConnectScope.OpenIdProfile,
                // ResponseType is set to request the id_token - which contains basic information about the signed-in user
                ResponseType = OpenIdConnectResponseType.IdToken,
                // ValidateIssuer set to false to allow personal and work accounts from any organization to sign in to your application
                // To only allow users from a single organizations, set ValidateIssuer to true and 'tenant' setting in web.config to the tenant name
                // To allow users from only a list of specific organizations, set ValidateIssuer to true and use ValidIssuers parameter 
                TokenValidationParameters = new TokenValidationParameters()
                {
                    ValidateIssuer = true
                },

                Notifications = new OpenIdConnectAuthenticationNotifications
                {
                    AuthenticationFailed = OnAuthenticationFailed
                }
            }
        );
    }

В Azure для поддерживаемых типов учетных записей установлен один клиент Azure Single Tenant setting

Что мне не хватает для принудительного входа в систему из одной организации?

1 Ответ

0 голосов
/ 24 марта 2020

Возможно, вам придется указать, какие арендаторы разрешены. Попробуйте добавить следующее к вашему TokenValidationParameters

ValidIssuers = new List<string>()
{
    "https://login.microsoftonline.com/<your-tenant-id>"
}
...