use*_*456 7 c# ws-security claims-based-identity jwt thinktecture-ident-server
我刚刚设置了一个SelfHost(InMem with WS-Fed) Thinktecture IdentityServer3项目示例,我正在尝试使用它来获取JWT,问题是我只使用alg接收使用非对称密钥签名的令牌,RS256但我需要使用alg对称,HS256所以我可以在客户端上使用相同的密钥.
我试图通过在服务器上配置依赖方而没有成功来遵循一些示例.
例如,我看到以下标记:
var relyingParty = new RelyingParty()
{
Enabled = true,
Realm = "urn:carbon",
Name = "Test party",
SymmetricSigningKey =
Convert.FromBase64String("R03W9kJERSSLH11Px+R/O7EYfAadSMQfZD5haQZj6eU="),
TokenLifeTime = 120
};
Run Code Online (Sandbox Code Playgroud)
但是,当我在我的代码上尝试它时,我有一个错误SymmetricSigningKey,它说:
'Thinktecture.IdentityServer.WsFederation.Models.RelyingParty'不包含'SymmetricSigningKey'的定义
我做错了什么?,提前谢谢!
UPDATE
启动文件的标记:
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);
}
Run Code Online (Sandbox Code Playgroud)
使用范围的标记:
new Scope
{
Name = "api1"
}
Run Code Online (Sandbox Code Playgroud)
使用的客户标记:
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())
}
}
Run Code Online (Sandbox Code Playgroud)
使用的用户标记:
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")
}
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
我只检查IdentityServer3的依赖方的类模型,对称签名密钥没有属性......我迷路了......
有任何想法吗?
| 归档时间: |
|
| 查看次数: |
450 次 |
| 最近记录: |