2017-08-15 6 views
0

「プロファイル」IDリソースを含まずに、ハイブリッド・フローでユーザー電子メールを渡すようにアイデンティティ・サーバー・コアを構成する方法を教えてください。アイデンティティ・サーバー4プロファイルを使用せずに電子メール・クレームを取得する

私は自分のサーバーにユーザーに関する可能な限りの情報を知りたいので、ユーザーのアカウントを作成するユーザーの電子メールが必要です。私の同意は、IDと電子メールの両方を要求することをユーザに要求することだけです。

私はエンティティフレームワークストアを使用してデータを保持しています+ Asp.netのコアアイデンティティをユーザー管理に使用しています。私は以下のConfigからDBを移入します。

これまで行ってきたことですが、ユーザーのメールでの申し立ては受け付けていません。私は「sid」を受け取っています。クライアント側では

public class Config 
{ 
    // scopes define the resources in your system 
    public static IEnumerable<IdentityResource> GetIdentityResources() 
    { 

     return new List<IdentityResource> 
     { 
      new IdentityResources.OpenId(), 
      new IdentityResources.Email 
      { 
       Required = true 
      } 
     }; 
    } 


    // clients want to access resources (aka scopes) 
    public static IEnumerable<Client> GetClients() 
    { 
      new Client 
      { 
       ClientId = "MyClient", 
       ClientName = "MyClient", 
       AllowedGrantTypes = GrantTypes.HybridAndClientCredentials, 

       RequireConsent = true, 

       ClientSecrets = 
       { 
        new Secret("secret".Sha256()) 
       }, 

       RedirectUris = { "http://localhost:27919/signin-oidc" }, 
       PostLogoutRedirectUris = { "http://localhost:27919" }, 

       AllowedScopes = 
       { 
        IdentityServerConstants.StandardScopes.OpenId, 
        IdentityServerConstants.StandardScopes.Email 
       }, 
       AllowOfflineAccess = true 
      } 



     }; 
    } 
} 

私がやっている:

// middleware for external openid connect authentication 
     var options = new OpenIdConnectOptions 
     { 
      SignInScheme = "Identity.External", 
      SignOutScheme = "Identity", 

      DisplayName = "MyClient", 
      Authority = Constants.AuthServer.BaseUrl, 

      ClientId = "MyClient", 
      ClientSecret = "secret", 

      ResponseType = "code id_token", 

      //Scopes are entered below, outside this constructor 

      GetClaimsFromUserInfoEndpoint = true, 


      RequireHttpsMetadata = false //TODO: make true, it is false for development only 


     }; 
     //Adding Scopes 
     options.Scope.Clear(); 
     options.Scope.Add("openid"); 
     options.Scope.Add("email"); 
     app.UseOpenIdConnectAuthentication(options); 

答えて

0

を私はアカウントにAsp.netアイデンティティに電子メールの請求に対応するコントローラは、ユーザが作成されたときに作成されたので、追加しなければならないことを考え出しました:各ユーザーの作成以下の

user.Claims.Add(new IdentityUserClaim<string> 
      { 
       ClaimType = "email", 
       ClaimValue = model.Email 
      }); 

var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; 
関連する問題