1
複数のアプリ用のOAuth共有承認サーバー
私のショップには、認証にOAuthトークンを使用する.NET Web APIがいくつかあります。現在、各Web APIは承認とリソースサーバーの両方です。ユーザーは、同じ資格情報を使用してこれらすべてのAPIに対して認証を行いますが、現時点では、各APIに対して個別に認証する必要があります。 共有認証サーバーの作成に興味があります(http://bitoftech.net/2014/10/27/json-web-token-asp-net-web-api-2-jwt-owin-authorization-server/)、しかし私はクレームの変換に悩まされています。次の例のように、発行されたトークンに(アプリケーションに固有の)カスタムクレームを追加できると便利です。 public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { /* validate credentials here... */ var identity = new ClaimsIdentity("JWT"); identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName)); identity.AddClaim(new Claim("sub", context.UserName)); identity.AddClaim(new Claim(ClaimTypes.Role, "Manager")); identity.AddClaim(new Claim(ClaimTypes.Role, "Supervisor")); var props = new AuthenticationProperties(new Dictionary<string, string> { { "audience", (context.ClientId == null) ? string.Empty : context.ClientId …