Remote ConfigureDefaultOptions
This commit is contained in:
parent
db9ae62632
commit
ae3dfcdb32
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Authentication.Facebook;
|
using Microsoft.AspNetCore.Authentication.Facebook;
|
||||||
using Microsoft.AspNetCore.Authentication.Facebook.Internal;
|
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.Extensions.DependencyInjection
|
namespace Microsoft.Extensions.DependencyInjection
|
||||||
{
|
{
|
||||||
|
|
@ -17,9 +15,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
=> services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions);
|
=> services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions);
|
||||||
|
|
||||||
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action<FacebookOptions> configureOptions)
|
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action<FacebookOptions> configureOptions)
|
||||||
{
|
=> services.AddOAuthAuthentication<FacebookOptions, FacebookHandler>(authenticationScheme, configureOptions);
|
||||||
services.AddSingleton<ConfigureDefaultOptions<FacebookOptions>, FacebookConfigureOptions>();
|
|
||||||
return services.AddOAuthAuthentication<FacebookOptions, FacebookHandler>(authenticationScheme, configureOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Authentication.Facebook.Internal
|
|
||||||
{
|
|
||||||
public class FacebookConfigureOptions : ConfigureDefaultOptions<FacebookOptions>
|
|
||||||
{
|
|
||||||
public FacebookConfigureOptions(IConfiguration config) :
|
|
||||||
base(FacebookDefaults.AuthenticationScheme,
|
|
||||||
options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+FacebookDefaults.AuthenticationScheme).Bind(options))
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Authentication.Google;
|
using Microsoft.AspNetCore.Authentication.Google;
|
||||||
using Microsoft.AspNetCore.Authentication.Google.Internal;
|
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.Extensions.DependencyInjection
|
namespace Microsoft.Extensions.DependencyInjection
|
||||||
{
|
{
|
||||||
|
|
@ -17,9 +15,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
=> services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions);
|
=> services.AddGoogleAuthentication(GoogleDefaults.AuthenticationScheme, configureOptions);
|
||||||
|
|
||||||
public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action<GoogleOptions> configureOptions)
|
public static IServiceCollection AddGoogleAuthentication(this IServiceCollection services, string authenticationScheme, Action<GoogleOptions> configureOptions)
|
||||||
{
|
=> services.AddOAuthAuthentication<GoogleOptions, GoogleHandler>(authenticationScheme, configureOptions);
|
||||||
services.AddSingleton<ConfigureDefaultOptions<GoogleOptions>, GoogleConfigureOptions>();
|
|
||||||
return services.AddOAuthAuthentication<GoogleOptions, GoogleHandler>(authenticationScheme, configureOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Authentication.Google.Internal
|
|
||||||
{
|
|
||||||
public class GoogleConfigureOptions : ConfigureDefaultOptions<GoogleOptions>
|
|
||||||
{
|
|
||||||
public GoogleConfigureOptions(IConfiguration config) :
|
|
||||||
base(GoogleDefaults.AuthenticationScheme,
|
|
||||||
options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+GoogleDefaults.AuthenticationScheme).Bind(options))
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Authentication.JwtBearer.Internal
|
|
||||||
{
|
|
||||||
public class JwtBearerConfigureOptions : ConfigureDefaultOptions<JwtBearerOptions>
|
|
||||||
{
|
|
||||||
// Bind to "Bearer" section by default
|
|
||||||
public JwtBearerConfigureOptions(IConfiguration config) :
|
|
||||||
base(JwtBearerDefaults.AuthenticationScheme,
|
|
||||||
options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+JwtBearerDefaults.AuthenticationScheme).Bind(options))
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer.Internal;
|
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.Extensions.DependencyInjection
|
namespace Microsoft.Extensions.DependencyInjection
|
||||||
{
|
{
|
||||||
|
|
@ -21,7 +19,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action<JwtBearerOptions> configureOptions)
|
public static IServiceCollection AddJwtBearerAuthentication(this IServiceCollection services, string authenticationScheme, Action<JwtBearerOptions> configureOptions)
|
||||||
{
|
{
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerPostConfigureOptions>());
|
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JwtBearerOptions>, JwtBearerPostConfigureOptions>());
|
||||||
services.AddSingleton<ConfigureDefaultOptions<JwtBearerOptions>, JwtBearerConfigureOptions>();
|
|
||||||
return services.AddScheme<JwtBearerOptions, JwtBearerHandler>(authenticationScheme, configureOptions);
|
return services.AddScheme<JwtBearerOptions, JwtBearerHandler>(authenticationScheme, configureOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.csproj" />
|
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication\Microsoft.AspNetCore.Authentication.csproj" />
|
||||||
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="$(IdentityModelOpenIdVersion)" />
|
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="$(IdentityModelOpenIdVersion)" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal
|
|
||||||
{
|
|
||||||
public class MicrosoftAccountConfigureOptions : ConfigureDefaultOptions<MicrosoftAccountOptions>
|
|
||||||
{
|
|
||||||
// Bind to "Microsoft" section by default
|
|
||||||
public MicrosoftAccountConfigureOptions(IConfiguration config) :
|
|
||||||
base(MicrosoftAccountDefaults.AuthenticationScheme,
|
|
||||||
options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+MicrosoftAccountDefaults.AuthenticationScheme).Bind(options))
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Authentication.MicrosoftAccount;
|
using Microsoft.AspNetCore.Authentication.MicrosoftAccount;
|
||||||
using Microsoft.AspNetCore.Authentication.MicrosoftAccount.Internal;
|
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.Extensions.DependencyInjection
|
namespace Microsoft.Extensions.DependencyInjection
|
||||||
{
|
{
|
||||||
|
|
@ -17,9 +15,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
=> services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions);
|
=> services.AddMicrosoftAccountAuthentication(MicrosoftAccountDefaults.AuthenticationScheme, configureOptions);
|
||||||
|
|
||||||
public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action<MicrosoftAccountOptions> configureOptions)
|
public static IServiceCollection AddMicrosoftAccountAuthentication(this IServiceCollection services, string authenticationScheme, Action<MicrosoftAccountOptions> configureOptions)
|
||||||
{
|
=> services.AddOAuthAuthentication<MicrosoftAccountOptions, MicrosoftAccountHandler>(authenticationScheme, configureOptions);
|
||||||
services.AddSingleton<ConfigureDefaultOptions<MicrosoftAccountOptions>, MicrosoftAccountConfigureOptions>();
|
|
||||||
return services.AddOAuthAuthentication<MicrosoftAccountOptions, MicrosoftAccountHandler>(authenticationScheme, configureOptions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal
|
|
||||||
{
|
|
||||||
internal class OpenIdConnectConfigureOptions : ConfigureDefaultOptions<OpenIdConnectOptions>
|
|
||||||
{
|
|
||||||
// Bind to "OpenIdConnect" section by default
|
|
||||||
public OpenIdConnectConfigureOptions(IConfiguration config) :
|
|
||||||
base(OpenIdConnectDefaults.AuthenticationScheme,
|
|
||||||
options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+OpenIdConnectDefaults.AuthenticationScheme).Bind(options))
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -12,6 +12,5 @@
|
||||||
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
||||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||||
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="$(IdentityModelOpenIdVersion)" />
|
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="$(IdentityModelOpenIdVersion)" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect.Internal;
|
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.Extensions.DependencyInjection
|
namespace Microsoft.Extensions.DependencyInjection
|
||||||
{
|
{
|
||||||
|
|
@ -21,7 +19,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action<OpenIdConnectOptions> configureOptions)
|
public static IServiceCollection AddOpenIdConnectAuthentication(this IServiceCollection services, string authenticationScheme, Action<OpenIdConnectOptions> configureOptions)
|
||||||
{
|
{
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>());
|
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<OpenIdConnectOptions>, OpenIdConnectPostConfigureOptions>());
|
||||||
services.AddSingleton<ConfigureDefaultOptions<OpenIdConnectOptions>, OpenIdConnectConfigureOptions>();
|
|
||||||
return services.AddRemoteScheme<OpenIdConnectOptions, OpenIdConnectHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
return services.AddRemoteScheme<OpenIdConnectOptions, OpenIdConnectHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Authentication.Twitter.Internal
|
|
||||||
{
|
|
||||||
public class TwitterConfigureOptions : ConfigureDefaultOptions<TwitterOptions>
|
|
||||||
{
|
|
||||||
// Bind to "Twitter" section by default
|
|
||||||
public TwitterConfigureOptions(IConfiguration config) :
|
|
||||||
base(TwitterDefaults.AuthenticationScheme,
|
|
||||||
options => config.GetSection("Microsoft:AspNetCore:Authentication:Schemes:"+TwitterDefaults.AuthenticationScheme).Bind(options))
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
<ProjectReference Include="..\Microsoft.AspNetCore.Authentication.OAuth\Microsoft.AspNetCore.Authentication.OAuth.csproj" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Authentication.Twitter;
|
using Microsoft.AspNetCore.Authentication.Twitter;
|
||||||
using Microsoft.AspNetCore.Authentication.Twitter.Internal;
|
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.Extensions.DependencyInjection
|
namespace Microsoft.Extensions.DependencyInjection
|
||||||
{
|
{
|
||||||
|
|
@ -21,7 +19,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action<TwitterOptions> configureOptions)
|
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action<TwitterOptions> configureOptions)
|
||||||
{
|
{
|
||||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>());
|
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>());
|
||||||
services.AddSingleton<ConfigureDefaultOptions<TwitterOptions>, TwitterConfigureOptions>();
|
|
||||||
return services.AddRemoteScheme<TwitterOptions, TwitterHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
return services.AddRemoteScheme<TwitterOptions, TwitterHandler>(authenticationScheme, authenticationScheme, configureOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -40,68 +39,6 @@ namespace Microsoft.AspNetCore.Authentication.Facebook
|
||||||
Assert.Equal(FacebookDefaults.AuthenticationScheme, scheme.DisplayName);
|
Assert.Equal(FacebookDefaults.AuthenticationScheme, scheme.DisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddCanBindAgainstDefaultConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppId", "<id>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AppSecret", "<secret>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:AuthorizationEndpoint", "<authEndpoint>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:BackchannelTimeout", "0.0:0:30"},
|
|
||||||
//{"Facebook:CallbackPath", "/callbackpath"}, // PathString doesn't convert
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:ClaimsIssuer", "<issuer>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:RemoteAuthenticationTimeout", "0.0:0:30"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SaveTokens", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SendAppSecretProof", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:SignInScheme", "<signIn>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:TokenEndpoint", "<tokenEndpoint>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Facebook:UserInformationEndpoint", "<userEndpoint>"},
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection()
|
|
||||||
.AddSingleton<IConfigureOptions<FacebookOptions>, ConfigureDefaults<FacebookOptions>>()
|
|
||||||
.AddFacebookAuthentication()
|
|
||||||
.AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<FacebookOptions>>().Get(FacebookDefaults.AuthenticationScheme);
|
|
||||||
Assert.Equal("<id>", options.AppId);
|
|
||||||
Assert.Equal("<secret>", options.AppSecret);
|
|
||||||
Assert.Equal("<authEndpoint>", options.AuthorizationEndpoint);
|
|
||||||
Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout);
|
|
||||||
//Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert
|
|
||||||
Assert.Equal("<issuer>", options.ClaimsIssuer);
|
|
||||||
Assert.Equal("<id>", options.ClientId);
|
|
||||||
Assert.Equal("<secret>", options.ClientSecret);
|
|
||||||
Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout);
|
|
||||||
Assert.True(options.SaveTokens);
|
|
||||||
Assert.True(options.SendAppSecretProof);
|
|
||||||
Assert.Equal("<signIn>", options.SignInScheme);
|
|
||||||
Assert.Equal("<tokenEndpoint>", options.TokenEndpoint);
|
|
||||||
Assert.Equal("<userEndpoint>", options.UserInformationEndpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddWithDelegateIgnoresConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Facebook:AppId", "<id>"},
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection().AddFacebookAuthentication(o => o.SaveTokens = false).AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<FacebookOptions>>().Get(FacebookDefaults.AuthenticationScheme);
|
|
||||||
Assert.Null(options.AppId);
|
|
||||||
Assert.False(options.SaveTokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ThrowsIfAppIdMissing()
|
public async Task ThrowsIfAppIdMissing()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -39,65 +38,6 @@ namespace Microsoft.AspNetCore.Authentication.Google
|
||||||
Assert.Equal(GoogleDefaults.AuthenticationScheme, scheme.DisplayName);
|
Assert.Equal(GoogleDefaults.AuthenticationScheme, scheme.DisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddCanBindAgainstDefaultConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientId", "<id>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:ClientSecret", "<secret>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:AuthorizationEndpoint", "<authEndpoint>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:BackchannelTimeout", "0.0:0:30"},
|
|
||||||
//{"Google:CallbackPath", "/callbackpath"}, // PathString doesn't convert
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:ClaimsIssuer", "<issuer>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:RemoteAuthenticationTimeout", "0.0:0:30"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:SaveTokens", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:SendAppSecretProof", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:SignInScheme", "<signIn>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:TokenEndpoint", "<tokenEndpoint>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Google:UserInformationEndpoint", "<userEndpoint>"},
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection()
|
|
||||||
.AddSingleton<IConfigureOptions<GoogleOptions>, ConfigureDefaults<GoogleOptions>>()
|
|
||||||
.AddGoogleAuthentication()
|
|
||||||
.AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<GoogleOptions>>().Get(GoogleDefaults.AuthenticationScheme);
|
|
||||||
Assert.Equal("<authEndpoint>", options.AuthorizationEndpoint);
|
|
||||||
Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout);
|
|
||||||
//Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert
|
|
||||||
Assert.Equal("<issuer>", options.ClaimsIssuer);
|
|
||||||
Assert.Equal("<id>", options.ClientId);
|
|
||||||
Assert.Equal("<secret>", options.ClientSecret);
|
|
||||||
Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout);
|
|
||||||
Assert.True(options.SaveTokens);
|
|
||||||
Assert.Equal("<signIn>", options.SignInScheme);
|
|
||||||
Assert.Equal("<tokenEndpoint>", options.TokenEndpoint);
|
|
||||||
Assert.Equal("<userEndpoint>", options.UserInformationEndpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddWithDelegateIgnoresConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Google:ClientId", "<id>"},
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection().AddGoogleAuthentication(o => o.SaveTokens = false).AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<GoogleOptions>>().Get(GoogleDefaults.AuthenticationScheme);
|
|
||||||
Assert.Null(options.ClientId);
|
|
||||||
Assert.False(options.SaveTokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ChallengeWillTriggerRedirection()
|
public async Task ChallengeWillTriggerRedirection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -39,67 +38,6 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer
|
||||||
Assert.Null(scheme.DisplayName);
|
Assert.Null(scheme.DisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddCanBindAgainstDefaultConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", "<audience>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", "<authority>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:BackchannelTimeout", "0.0:0:30"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Challenge", "<challenge>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:ClaimsIssuer", "<issuer>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:IncludeErrorDetails", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:MetadataAddress", "<metadata>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RefreshOnIssuerKeyNotFound", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:SaveToken", "true"},
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection()
|
|
||||||
.AddSingleton<IConfigureOptions<JwtBearerOptions>, ConfigureDefaults<JwtBearerOptions>>()
|
|
||||||
.AddJwtBearerAuthentication()
|
|
||||||
.AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<JwtBearerOptions>>().Get(JwtBearerDefaults.AuthenticationScheme);
|
|
||||||
Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout);
|
|
||||||
Assert.Equal("<audience>", options.Audience);
|
|
||||||
Assert.Equal("<authority>", options.Authority);
|
|
||||||
Assert.Equal("<challenge>", options.Challenge);
|
|
||||||
Assert.Equal("<issuer>", options.ClaimsIssuer);
|
|
||||||
Assert.True(options.IncludeErrorDetails);
|
|
||||||
Assert.Equal("<metadata>", options.MetadataAddress);
|
|
||||||
Assert.True(options.RefreshOnIssuerKeyNotFound);
|
|
||||||
Assert.False(options.RequireHttpsMetadata);
|
|
||||||
Assert.True(options.SaveToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddWithDelegateOverridesConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Audience", "<audience>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:Authority", "<authority>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Bearer:RequireHttpsMetadata", "false"}
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection()
|
|
||||||
.AddSingleton<IConfigureOptions<JwtBearerOptions>, ConfigureDefaults<JwtBearerOptions>>()
|
|
||||||
.AddJwtBearerAuthentication(o => o.Authority = "authority")
|
|
||||||
.AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<JwtBearerOptions>>().Get(JwtBearerDefaults.AuthenticationScheme);
|
|
||||||
Assert.Equal("<audience>", options.Audience);
|
|
||||||
Assert.Equal("authority", options.Authority);
|
|
||||||
}
|
|
||||||
|
|
||||||
[ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")]
|
[ConditionalFact(Skip = "Need to remove dependency on AAD since the generated tokens will expire")]
|
||||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||||
// https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179
|
// https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/179
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -40,65 +39,6 @@ namespace Microsoft.AspNetCore.Authentication.Tests.MicrosoftAccount
|
||||||
Assert.Equal(MicrosoftAccountDefaults.AuthenticationScheme, scheme.DisplayName);
|
Assert.Equal(MicrosoftAccountDefaults.AuthenticationScheme, scheme.DisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddCanBindAgainstDefaultConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientId", "<id>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClientSecret", "<secret>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:AuthorizationEndpoint", "<authEndpoint>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:BackchannelTimeout", "0.0:0:30"},
|
|
||||||
//{"Microsoft:CallbackPath", "/callbackpath"}, // PathString doesn't convert
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:ClaimsIssuer", "<issuer>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:RemoteAuthenticationTimeout", "0.0:0:30"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SaveTokens", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SendAppSecretProof", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:SignInScheme", "<signIn>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:TokenEndpoint", "<tokenEndpoint>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Microsoft:UserInformationEndpoint", "<userEndpoint>"},
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection()
|
|
||||||
.AddSingleton<IConfigureOptions<MicrosoftAccountOptions>, ConfigureDefaults<MicrosoftAccountOptions>>()
|
|
||||||
.AddMicrosoftAccountAuthentication()
|
|
||||||
.AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<MicrosoftAccountOptions>>().Get(MicrosoftAccountDefaults.AuthenticationScheme);
|
|
||||||
Assert.Equal("<authEndpoint>", options.AuthorizationEndpoint);
|
|
||||||
Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout);
|
|
||||||
//Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert
|
|
||||||
Assert.Equal("<issuer>", options.ClaimsIssuer);
|
|
||||||
Assert.Equal("<id>", options.ClientId);
|
|
||||||
Assert.Equal("<secret>", options.ClientSecret);
|
|
||||||
Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout);
|
|
||||||
Assert.True(options.SaveTokens);
|
|
||||||
Assert.Equal("<signIn>", options.SignInScheme);
|
|
||||||
Assert.Equal("<tokenEndpoint>", options.TokenEndpoint);
|
|
||||||
Assert.Equal("<userEndpoint>", options.UserInformationEndpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddWithDelegateIgnoresConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Microsoft:ClientId", "<id>"},
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection().AddMicrosoftAccountAuthentication(o => o.SaveTokens = true).AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<MicrosoftAccountOptions>>().Get(MicrosoftAccountDefaults.AuthenticationScheme);
|
|
||||||
Assert.Null(options.ClientId);
|
|
||||||
Assert.True(options.SaveTokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ChallengeWillTriggerApplyRedirectEvent()
|
public async Task ChallengeWillTriggerApplyRedirectEvent()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|
@ -30,33 +29,6 @@ namespace Microsoft.AspNetCore.Authentication.Test.OpenIdConnect
|
||||||
const string Signin = "/signin";
|
const string Signin = "/signin";
|
||||||
const string Signout = "/signout";
|
const string Signout = "/signout";
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddCanBindAgainstDefaultConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientId", "<id>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:ClientSecret", "<secret>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:RequireHttpsMetadata", "false"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:OpenIdConnect:Authority", "<auth>"}
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection()
|
|
||||||
.AddSingleton<IConfigureOptions<OpenIdConnectOptions>, ConfigureDefaults<OpenIdConnectOptions>>()
|
|
||||||
.AddOpenIdConnectAuthentication()
|
|
||||||
.AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<OpenIdConnectOptions>>().Get(OpenIdConnectDefaults.AuthenticationScheme);
|
|
||||||
Assert.Equal("<id>", options.ClientId);
|
|
||||||
Assert.Equal("<secret>", options.ClientSecret);
|
|
||||||
Assert.Equal("<auth>", options.Authority);
|
|
||||||
Assert.False(options.RequireHttpsMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests RedirectForSignOutContext replaces the OpenIdConnectMesssage correctly.
|
/// Tests RedirectForSignOutContext replaces the OpenIdConnectMesssage correctly.
|
||||||
/// summary>
|
/// summary>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ using Microsoft.AspNetCore.TestHost;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Options.Infrastructure;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Authentication.Twitter
|
namespace Microsoft.AspNetCore.Authentication.Twitter
|
||||||
|
|
@ -33,59 +32,6 @@ namespace Microsoft.AspNetCore.Authentication.Twitter
|
||||||
Assert.Equal(TwitterDefaults.AuthenticationScheme, scheme.DisplayName);
|
Assert.Equal(TwitterDefaults.AuthenticationScheme, scheme.DisplayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddCanBindAgainstDefaultConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerKey", "<key>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ConsumerSecret", "<secret>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Twitter:BackchannelTimeout", "0.0:0:30"},
|
|
||||||
//{"Twitter:CallbackPath", "/callbackpath"}, // PathString doesn't convert
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Twitter:ClaimsIssuer", "<issuer>"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Twitter:RemoteAuthenticationTimeout", "0.0:0:30"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SaveTokens", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SendAppSecretProof", "true"},
|
|
||||||
{"Microsoft:AspNetCore:Authentication:Schemes:Twitter:SignInScheme", "<signIn>"},
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection()
|
|
||||||
.AddSingleton<IConfigureOptions<TwitterOptions>, ConfigureDefaults<TwitterOptions>>()
|
|
||||||
.AddTwitterAuthentication()
|
|
||||||
.AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<TwitterOptions>>().Get(TwitterDefaults.AuthenticationScheme);
|
|
||||||
Assert.Equal(new TimeSpan(0, 0, 0, 30), options.BackchannelTimeout);
|
|
||||||
//Assert.Equal("/callbackpath", options.CallbackPath); // NOTE: PathString doesn't convert
|
|
||||||
Assert.Equal("<issuer>", options.ClaimsIssuer);
|
|
||||||
Assert.Equal("<key>", options.ConsumerKey);
|
|
||||||
Assert.Equal("<secret>", options.ConsumerSecret);
|
|
||||||
Assert.Equal(new TimeSpan(0, 0, 0, 30), options.RemoteAuthenticationTimeout);
|
|
||||||
Assert.True(options.SaveTokens);
|
|
||||||
Assert.Equal("<signIn>", options.SignInScheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void AddWithDelegateIgnoresConfig()
|
|
||||||
{
|
|
||||||
var dic = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{"Twitter:ConsumerKey", "<key>"},
|
|
||||||
};
|
|
||||||
var configurationBuilder = new ConfigurationBuilder();
|
|
||||||
configurationBuilder.AddInMemoryCollection(dic);
|
|
||||||
var config = configurationBuilder.Build();
|
|
||||||
var services = new ServiceCollection().AddTwitterAuthentication(o => o.SaveTokens = true).AddSingleton<IConfiguration>(config);
|
|
||||||
var sp = services.BuildServiceProvider();
|
|
||||||
|
|
||||||
var options = sp.GetRequiredService<IOptionsSnapshot<TwitterOptions>>().Get(TwitterDefaults.AuthenticationScheme);
|
|
||||||
Assert.Null(options.ConsumerKey);
|
|
||||||
Assert.True(options.SaveTokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ChallengeWillTriggerApplyRedirectEvent()
|
public async Task ChallengeWillTriggerApplyRedirectEvent()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue