認証トピックは初めてです。
私のアプローチは、リソースにアクセスするためにidentityserver3を使用することです.OAuth2でリソース所有者クライアントフローを使用したいのですが、Windowsユーザーでは、ログインしたWindowsユーザーでアクセストークンを取得できるサンプルのようなものが必要です.
https://github.com/IdentityServer/WindowsAuthenticationを外部 ID プロバイダーとしてセットアップしようとしました。https ://github.com/IdentityServer/IdentityServer3/issues/1157に見られるように、ID サーバーに WS-Fed プロバイダーとして登録しました。
class Startup
{
public void Configuration(IAppBuilder app)
{
var factory = InMemoryFactory.Create(
scopes: Scopes.Get(),
clients: Clients.Get(),
users: Users.Get());
var AuthenticationOptions = new Thinktecture.IdentityServer.Core.Configuration.AuthenticationOptions();
AuthenticationOptions.EnableLocalLogin = true;
AuthenticationOptions.EnableLoginHint = true;
AuthenticationOptions.EnableSignOutPrompt = true;
AuthenticationOptions.IdentityProviders = ConfigureIdentityProviders;
var userService = new ExternalRegistrationUserService();
factory.UserService = new Registration<IUserService>(resolver => userService);
var options = new IdentityServerOptions
{
SiteName = "Single Sign On",
Factory = factory,
RequireSsl = false,
EnableWelcomePage = true,
AuthenticationOptions = AuthenticationOptions,
};
app.UseIdentityServer(options);
}
private static Thinktecture.IdentityServer.Core.Configuration.AuthenticationOptions GetAuthenticationOptions()
{
var authenticationOptions = new Thinktecture.IdentityServer.Core.Configuration.AuthenticationOptions()
{
EnableSignOutPrompt = true,
EnablePostSignOutAutoRedirect = true,
PostSignOutAutoRedirectDelay = 0,
IdentityProviders = ConfigureIdentityProviders
};
return authenticationOptions;
}
private static void ConfigureIdentityProviders(IAppBuilder app, string signInAsType)
{
var adfs = new WsFederationAuthenticationOptions
{
AuthenticationType = "adfs",
Caption = "Windows Account",
SignInAsAuthenticationType = signInAsType,
MetadataAddress = "http://localhost:6739", //url to WebHost project
Wtrealm = "urn:idsrv3"
};
app.UseWsFederationAuthentication(adfs);
}
}
「外部ログイン」ボタンがありますが、これを押すと HTTP 500 エラーが発生します。
質問:
私は正しい道を進んでいますか?
500 エラーは正常ではないと思います。これを機能させるための次のステップは何ですか?
「最も単純な OAuth2 ウォークスルー」のように、プログラムでアクセス トークンを取得するにはどうすればよいですか? 例:
public TokenResponse GetToken(string username, string password, string scope) { OAuth2Client client = new OAuth2Client( new Uri("http://localhost.fiddler:44333/windows/authentication"), //client ID "carbon", //client secret "21B5F798-BE55-42BC-8AA8-0025B903DC3B"); return client.RequestResourceOwnerPasswordAsync(username, password, scope).Result; }