标签: identityserver3


Identity Server 3 - 客户端应用程序未知或未经授权

我收到错误'客户端应用程序未知或未经授权.访问我的网站的受保护区域时.

这是我的客户:

public static class Clients
{
    public static IEnumerable<Client> Get()
    {
        return new[]
        {
            new Client
            {
                Enabled = true,
                ClientName = "Web Application",
                ClientId = "webapplication",
                Flow = Flows.AuthorizationCode,

                ClientSecrets = new List<Secret>
                {
                    new Secret("webappsecret".Sha256())
                },

                RedirectUris = new List<string>
                {
                    UrlManager.WebApplication
                },
                PostLogoutRedirectUris = new List<string>
                {
                    UrlManager.WebApplication
                },

                AllowedScopes = new List<string>
                {
                    Constants.StandardScopes.OpenId,
                    Constants.StandardScopes.Profile,
                    Constants.StandardScopes.Email,
                    Constants.StandardScopes.Roles,
                    Constants.StandardScopes.OfflineAccess,
                    "read",
                    "write"
                }
            }
        };
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的Web应用程序启动:

public class Startup
{
    public void Configuration(IAppBuilder app)
    { …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc oauth oauth-2.0 openid-connect identityserver3

9
推荐指数
2
解决办法
6177
查看次数

如何在请求标头上调用需要承载令牌的NSwag客户端方法?

我没有准确了解NSwag如何与IdentityServerX承载令牌进行交互并按常规添加请求标头?我的主机api应用程序使用LDAP身份验证实现IdentityServer3,据我了解; 如果任何主机需要一个令牌进行身份验证,那么任何客户端都必须在请求头上发送它.那么我如何在为NSwag客户工作时处理它呢?

任何想法都赞赏.谢谢.

.net asp.net-web-api identityserver3 nswag

9
推荐指数
3
解决办法
6029
查看次数

多个 IdentityServer 联合:错误无法取消保护消息。状态

我正在尝试创建一个主从类型配置以使用 IdentityServer4 进行身份验证,如下所示

MyMasterIdentityServer0 (Master) - receives id_token and gives access_token
|---> MySlaveIdentityServer1 (Basic Auth)
|---> MySlaveIdentityServer2 (Windows Auth)
|---> MySlaveIdentityServer3 (SmartCard Certificate Auth)
|---> MySlaveIdentityServer4 (SAML SSO Auth)
|---> Cloud Demo IdentityServer
|---> Google Auth
|---> Facebook Auth
|---> Microsoft Auth
|---> Twitter Auth
Run Code Online (Sandbox Code Playgroud)

我所有的应用程序和 api 都将指向MyMasterIdentityServer0并使用它进行身份验证

用户可以选择使用上述任何提供程序进行身份验证。他们可以选择用户名/密码,在这种情况下,他们应该被重定向到MySlaveIdentityServer1(基本身份验证),或者他们可以选择使用他们的 AD 帐户使用 Windows 身份验证,在这种情况下他们将被重定向到MySlaveIdentityServer2(Windows 身份验证),或者选择任何其他提供商。

用户通过身份验证后,他会从提供者服务器接收一个 id_token 并重定向回MyMasterIdentityServer0,在那里使用 Provider 和 ProviderUserId 查找外部用户,然后根据他的权限获得一个 access_token 以访问应用程序/api。

我面临的问题是 IdentityServer 主从配置对我不起作用,并且在用户在身份验证后重定向回主服务器时给我一个错误Unable to unprotect the message.State。我尝试查找问题,AuthO …

authentication federation oauth-2.0 identityserver3 identityserver4

9
推荐指数
1
解决办法
6190
查看次数

注册IdentityServer3后自动登录本地用户

使用IdentityServer3我需要在用户完成注册过程后自动登录并将本地用户重定向回客户端应用程序.有一种优雅的方式来做到这一点?从我的挖掘中我怀疑不是,在哪种情况下我可以用来实现这个目标?

我能够使用自定义用户服务为外部用户实现此目的,但这使用了部分登录.但是,对于本地用户,在用户名和密码登录之前,他们不在用户服务处理的身份验证过程中.

另请注意,我无法访问用户密码,因为注册过程由多个屏幕/视图覆盖,因为在这种情况下,他们需要在注册过程中验证其电子邮件.

进展:

我找到了这个https://github.com/IdentityServer/IdentityServer3/issues/563,但还没有找到如何触发重定向.

我正在尝试使用以下方式发出身份验证令牌:

var localAuthResult = userService.AuthenticateLocalAsync(user);
Request.GetOwinContext().Authentication.SignIn(new ClaimsIdentity(localAuthResult.Result.User.Claims, Thinktecture.IdentityServer.Core.Constants.PrimaryAuthenticationType));
Run Code Online (Sandbox Code Playgroud)

但到目前为止我能做的最好的事情是将用户重定向回登录界面:

HttpCookie cookie = Request.Cookies["signin"]; // Stored previously at beginning of registration process
return Redirect("~/core/login?signin=" + cookie.Value);
Run Code Online (Sandbox Code Playgroud)

c# oauth-2.0 owin-security identityserver3

8
推荐指数
1
解决办法
4986
查看次数

如何使用WCF和WIF的JWT令牌?

一般注意事项

我们正在使用IdentityServer3,并且到目前为止对它非常满意.
在MS和Thinktecture OWIN中间件的帮助下,我们可以非常轻松地保护MVC和ASP.NET Web API应用程序.

我们正在为之工作的客户端仍然有很多SOAP WCF服务,而这正是我们陷入困境的地方.

安装程序

我不会撒谎,我远没有体验过WCF,我只是将它用于非常基本的场景 - 理解basicHttpBinding,没有传输,也没有消息安全.

这就是我想要实现的目标:

  • 客户端从IdentityServer获取JWT访问令牌
  • 不知何故,令牌最终出现在SOAP消息头中
  • WCF读取并验证令牌
  • WCF根据某些标准检查索赔并执行授权

我无法完成第三步.

服务器设置

  • 我使用的是ws2007FederationHttpBindingTransportWithMessageCredential安全模式.消息包含a BearerKey且令牌属于类型urn:ietf:params:oauth:token-type:jwt
  • 该服务使用WIF标识管道,我在其中添加JwtSecurityTokenHandlerSystem.IdentityModel.Tokens.JwtNuGet包

客户端设置

  • STS发出的JWT令牌包装在一个BinarySecurityTokenXML元素中,它本身包含在一个GenericXmlSecurityElement
  • 该令牌被用作的一个参数CreateChannelWithIssuedTokenChannelFactory

怎么了

该标记位于SOAP标头中并传递给JwtSecurityTokenHandler.
但随后会抛出异常:

System.ServiceModel.Security.MessageSecurityException: Message security verification failed. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Xml.XmlBufferReader.GetChars(Int32 offset, Int32 length, Char[] chars)
   at System.Xml.XmlBufferReader.GetString(Int32 offset, Int32 length)
   at System.Xml.StringHandle.GetString()
   at System.Xml.XmlBaseReader.ReadEndElement()
   at …
Run Code Online (Sandbox Code Playgroud)

wcf wif jwt identityserver3

8
推荐指数
1
解决办法
6953
查看次数

身份服务器和用户模拟

我有两个站点https://www.somesite.com(用户站点)和https://admin.anothersite.com(管理站点),我使用Identity Server 3进行访问控制,这是托管在https:// identity.somesite.com.

这些站点在身份服务器中配置为具有基于cookie的身份验证的同一客户端(不同的重定向URL).我想提供一种机制,管理站点的用户可以模拟用户站点的用户.

我已经看到我可以使用它发出cookie IssueLoginCookie,但是这个调用需要在身份服务器上,所以鉴于它在另一个域上,我无法看到它是如何工作的.

如何在身份服务器中支持用户模拟?

更新

我现在有管理站点生成一个这样的URL:

var url = 'http://localhost:61826/connect/authorize'
    + '?state=' + encodeURIComponent(((Date.now() + Math.random()) * Math.random()).toString().replace(".", ""))
    + '&nonce=' + encodeURIComponent(((Date.now() + Math.random()) * Math.random()).toString().replace(".", ""))
    + '&client_id=mvc'
    + '&redirect_uri=' + encodeURIComponent('http://localhost:64822/')
    + '&scope=' + encodeURIComponent('openid profile roles api1')
    + '&acr_values=' + encodeURIComponent('loginas:3230')
    + '&response_type=' + encodeURIComponent('id_token token')
    + '&prompt=login';

window.location.href = url;
Run Code Online (Sandbox Code Playgroud)

这允许我PreAuthenticateAsync在我的自定义上的方法中拾取登录事件IUserService并拦截登录.我目前的实施是:

public override async Task PreAuthenticateAsync(PreAuthenticationContext context)
{
    if (context.SignInMessage.AcrValues.Any(acr …
Run Code Online (Sandbox Code Playgroud)

cookies identityserver3

8
推荐指数
1
解决办法
1012
查看次数

IdentityServer3 - 自定义登录和注册屏幕

我们计划整合身份服务器3.

我们有自己的登录页面,其中包括:

  1. 登录部分
  2. 帐户登记科,

是否可以为身份服务器身份验证设置自定义登录页面,该页面具有上述部分

identityserver3

8
推荐指数
1
解决办法
5356
查看次数

无法从众所周知的/ openid配置中获取配置

我正在使用ASP.NET 5,在我的解决方案中我有Web API,Identity Server和Angular 2项目,我使用Identity Server验证Angular 2客户端,Angular 2客户端通过在http请求中传递令牌和web api身份验证来使用web api令牌并给出响应,为此我编写了一个自定义属性,用于检查用户是否经过身份验证

当我使用API​​时,我遇到异常,Web API返回500内部服务器错误.

System.InvalidOperationException:IDX10803:无法从以下位置获取配置:' http://xx.xx.xx.x:3926/.well-known/openid-configuration '.---> System.IO.IOException:IDX10804:无法从以下位置检索文档:' http://xx.xx.xx.x:3926/.well-known/openid-configuration '.---> System.AggregateException:发生一个或多个错误.---> System.Net.Http.HttpRequestException:发送请求时发生错误.---> System.Net.WebException:无法连接到远程服务器---> System.Net.Sockets.SocketException:连接尝试失败,因为连接方在一段时间后没有正确响应,或建立连接失败,因为连接的主机无法在System.Net.Service.ConnectSocketInternal的System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)上响应xx.xx.xx.x:3926(布尔connectFailure,Socket s4,Socket s6,Socket&套接字,IP地址和地址,ConnectSocketState状态,IAsyncResult asyncResult,异常和异常)

asp.net-web-api2 asp.net-core-mvc identityserver3 asp.net-core angular

8
推荐指数
3
解决办法
1万
查看次数

C#.NET:服务器无法验证Angular Client [IdentityServer]

所以我有以下设置:

前端:AngularJS App

后端:使用Identity Server的WebApi来验证客户端

在我的后端,我创建了一个新的内存客户端,如下所示:

new Client
{
    Enabled = true,
    ClientId = "myapp.mycompany",
    ClientUri = "https://myapp.mycompany.com",
    ClientName = "My Client",
    Flow = Flows.Implicit,
    AllowAccessToAllScopes = true,
    IdentityTokenLifetime = 300,
    AccessTokenLifetime = 3600,
    RequireConsent = false,
    RedirectUris = new List<string>
    {
        "https://myapp.mycompany.com/assets/idSrv/callback.html",
        "https://myapp.mycompany.com/assets/idSrv/silentrefreshframe.html"
    },
    PostLogoutRedirectUris = new List<string>
    {
        "https://myapp.mycompany.com/index.html"
    }
},
Run Code Online (Sandbox Code Playgroud)

在我的前端,我有以下代码声明客户端,我使用oidc-token-manager.js客户端

var authority = 'https://sts.mycompany.com/identity';

return {
    baseUri: protocol,
    tokenConfig: {
        'client_id': 'myapp.mycompany',
        'authority': authority,
        'redirect_uri': 'https://myapp.mycompany.com/assets/idSrv/callback.html',
        'post_logout_redirect_uri': 'https://myapp.mycompany.com/index.html',
        'response_type': 'id_token token',
        'scope': 'openid profile roleScope webApiScope', …
Run Code Online (Sandbox Code Playgroud)

.net javascript c# identityserver3 angular

8
推荐指数
1
解决办法
275
查看次数