依赖方

时间:2015-07-07 23:15:06

标签: c# claims-based-identity ws-security jwt thinktecture-ident-server

我刚刚设置了SelfHost(InMem with WS-Fed) Thinktecture IdentityServer3 项目示例,我试图用它来获取 JWT ,问题是我只使用alg RS256接收使用非对称密钥签名的令牌,但我需要使用alg HS256来对称,因此我可以在客户端使用相同的密钥。

我尝试通过在服务器上配置依赖方来关注some examples,但没有成功。

例如,我看到以下标记:

var relyingParty = new RelyingParty()
{
    Enabled = true,
    Realm = "urn:carbon",
    Name = "Test party",
    SymmetricSigningKey = 
      Convert.FromBase64String("R03W9kJERSSLH11Px+R/O7EYfAadSMQfZD5haQZj6eU="),
    TokenLifeTime = 120
};

但是当我在我的代码上尝试时,我在SymmetricSigningKey上出错并且说:

  

' Thinktecture.IdentityServer.WsFederation.Models.RelyingParty'不   不包含' SymmetricSigningKey'

的定义

我做错了什么?,提前谢谢!

更新

启动文件的标记:

public void Configuration(IAppBuilder appBuilder)
{
    var factory = InMemoryFactory.Create(
        users: Users.Get(),
        clients: Clients.Get(),
        scopes: Scopes.Get()
    );

    var options = new IdentityServerOptions
    {
        IssuerUri = "https://idsrv3.com",
        SiteName = "Thinktecture IdentityServer3 - WsFed",

        SigningCertificate = Certificate.Get(),
        Factory = factory,
        PluginConfiguration = ConfigurePlugins,

    };

    appBuilder.UseIdentityServer(options);
}

private void ConfigurePlugins(IAppBuilder pluginApp, IdentityServerOptions options)
{
    var wsFedOptions = new WsFederationPluginOptions(options);

    // data sources for in-memory services
    wsFedOptions.Factory.Register(new Registration<IEnumerable<RelyingParty>>(RelyingParties.Get()));
    wsFedOptions.Factory.RelyingPartyService = new Registration<IRelyingPartyService>(typeof(InMemoryRelyingPartyService));

    pluginApp.UseWsFederationPlugin(wsFedOptions);
}

使用范围的标记:

new Scope
{
    Name = "api1"
}

使用的客户标记:

new Client
{
    ClientName = "Silicon on behalf of Carbon Client",
    ClientId = "carbon",
    Enabled = true,
    AccessTokenType = AccessTokenType.Jwt,

    Flow = Flows.ResourceOwner,
    ClientSecrets = new List<ClientSecret>
    {
        new ClientSecret("21B5F798-BE55-42BC-8AA8-0025B903DC3B".Sha256())
    }
}

使用的用户标记:

new InMemoryUser{Subject = "bob", Username = "bob", Password = "bob", 
    Claims = new Claim[]
    {
        new Claim(Constants.ClaimTypes.GivenName, "Bob"),
        new Claim(Constants.ClaimTypes.FamilyName, "Smith"),
        new Claim(Constants.ClaimTypes.Email, "BobSmith@email.com")
    }
}

更新

我只是查看IdentityServer3依赖方的class model,并且没有对称签名密钥的属性......我迷失了......

有什么想法吗?

0 个答案:

没有答案