0
AD FSサーバーでOAuth認証を構成するには、https://vcsjones.com/2015/05/04/authenticating-asp-net-5-to-ad-fs-oauth/のチュートリアルに従います。AD FS OAuth2:NotSupportedException:指定されたメソッドがサポートされていません
これは私の生の例外です:
System.NotSupportedException: Specified method is not supported.
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleSignInAsync(SignInContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.<SignInAsync>d__61.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Http.Authentication.Internal.DefaultAuthenticationManager.<SignInAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.<HandleRemoteCallbackAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.<HandleRequestAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware`1.<Invoke>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__6.MoveNext()
これは私のConfigureServices()メソッドです:
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddAuthentication(opts => opts.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme);
services.Configure<OAuthOptions>(opt =>
{
opt.AutomaticAuthenticate = true;
opt.AutomaticChallenge = true;
opt.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
opt.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
opt.ClientId = "44ADBF90-0626-4730-8EC7-2D007F59B8D3";
opt.ClientSecret = "abc123!";
opt.CallbackPath = new PathString("/oauth-callback");
opt.Events = new OAuthEvents
{
OnRedirectToAuthorizationEndpoint = ctx =>
{
var parameter = new Dictionary<string, string>
{
["resource"] = "https://myapp.dev"
};
var query = QueryHelpers.AddQueryString(ctx.RedirectUri, parameter);
ctx.Response.Redirect(query);
return Task.FromResult(0);
},
OnCreatingTicket = ctx =>
{
var token = new JwtSecurityToken(ctx.AccessToken);
var identity = new ClaimsIdentity(token.Claims, ctx.Options.AuthenticationScheme, "upn", "role");
ctx.Ticket = new AuthenticationTicket(new ClaimsPrincipal(identity), ctx.Ticket.Properties, ctx.Options.AuthenticationScheme);
return Task.FromResult(0);
}
};
opt.ClaimsIssuer = "https://myapp.dev";
opt.AuthorizationEndpoint = "https://adfs.mycompany.com/adfs/oauth2/authorize/";
opt.TokenEndpoint = "https://adfs.mycompany.com/adfs/oauth2/token/";
});
services.Configure<CookieAuthenticationOptions>(opt =>
{
opt.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
opt.AutomaticAuthenticate = true;
opt.AutomaticChallenge = true;
});
}
そして、私の設定()メソッド:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseCookieAuthentication();
app.UseOAuthAuthentication();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
は、事前にありがとうあなたが提供できるアドバイスのために。
EDIT
プロジェクトの依存関係:ユニークな値に
opt.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
変更、それを(:
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authentication.OAuth": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"StyleCop.Analyzers": {
"version": "1.0.0",
"type": "build"
},
"System.IdentityModel.Tokens.Jwt": "5.0.0",
エラーはかなり自明です。「指定されたメソッドはサポートされていません」。どのバージョンのパッケージを使用していますか? – DavidG
@DavidGの依存関係が質問に追加されました – jasonincode