标签: identityserver3

IdentityServer流程

IdentityServer支持在Flows枚举中定义并为客户端设置的不同OpenId Connect流.还有每种类型的流量,并在文档给他们很多的参考样本,但我找不到什么流是一个简单的定义列表的文件,如果他们是太明显言传.但我想他们不是.您能告诉我们这些差异的更多信息,也许我们可以将其添加到文档中吗?

那么什么是:隐式流,资源所有者密码凭证流,授权代码流,客户端凭证流,自定义授权流和混合流?还有哪些是OAuth流,哪些是OpenID Connect流?

谢谢!

openid oauth-2.0 thinktecture-ident-server openid-connect identityserver3

54
推荐指数
4
解决办法
3万
查看次数

IdentityServer:根据验证过程,远程证书无效

我正在尝试使用OWin和Thinktecture Identity Server设置SSO,但我没有运气获得SSL证书.至少我认为这是问题所在.当我在视觉工作室时,一切正常,但如果我尝试在我的机器上使用IIS,它会给我错误"远程证书根据验证程序无效".我也尝试使用IIS作为客户端将在visual studio中运行的实例视为令牌权限但我仍然得到相同的错误.任何人对我做错了什么有任何想法?

ssl identityserver3

30
推荐指数
3
解决办法
2万
查看次数

更新System.IdentityModel.Tokens.Jwt导致IdentityServer3客户端发生重大更改

希望很容易解决.

微软的System.IdentityModels.Tokens.Jwt软件包昨天在NuGet上更新4.0.2.206211351v5.0.不幸的是,这导致了一些"标准" IdentityServer3代码的突破性变化.即从他们的代码示例中提取,所以我想很多开发人员可能会在未来几天看到这个问题.

原始代码

使用v4.0.2.xxxxxx版本的软件包.我有

using System.IdentityModel.Tokens;
Run Code Online (Sandbox Code Playgroud)

在命名空间中.

然后在Configuration方法中开始如下:

public void Configuration(IAppBuilder app)
    {
        AntiForgeryConfig.UniqueClaimTypeIdentifier = "sub";

        JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();

        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = "Cookies"
        });

        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
        { ... };
Run Code Online (Sandbox Code Playgroud)

更新后

更新说明行后:

JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
Run Code Online (Sandbox Code Playgroud)

造成问题.

第一件事就是Class显然已经进入了System.IdentityModel.Tokens.Jwt命名空间,这个解决方案并不是那么糟糕.

但是,我现在收到Object reference required for a non-static field错误JwtSecurityTokenHandler.InboundClaimTypeMap.

我是否在这里遗漏了一些东西,另一个需要的库或者在Startup.Configuration()被调用之前发生了什么需要深入研究?

c# security identityserver3

26
推荐指数
1
解决办法
5784
查看次数

为外部身份验证创建部分登录Cookie

最近我使用Identity Server 3为我的Web API实现了2FA.如果登录是在本地进行的(使用IUserService),一切都按预期工作.现在,我希望能够通过发出部分登录cookie来进行此登录.这意味着我有一个API方法(POST),可以让用户在不进入主页面的情况下进行部分登录.要发出身份验证cookie,这就是我所做的(基于IS3扩展方法):

_owinContext.Environment.IssueLoginCookie(new AuthenticatedLogin
{
      IdentityProvider = Constants.ExternalAuthenticationType,
      Subject = userId,
      Name = identityId,
      Claims = new[] { new Claim(ClaimTypes.NameIdentifier, identityId) },
      AuthenticationMethod = Constants.AuthenticationMethods.TwoFactorAuthentication
});
Run Code Online (Sandbox Code Playgroud)

在此之后,我将用户重定向回登录页面,并完全登录到绕过2FA步骤的应用程序.我正在跳跃,这将使用户部分登录,但它完全登录用户.

注意:我实现Two Factor的方式基于IUserService中的AuthenticateLocalAsync方法.在这里,我更新AuthenticateResult以使用带有重定向路径的构造函数.API方法不会调用IUserService.它简单地发布了登录cookie.

编辑: 因此在检查IdentityServer3内部实现后,我现在能够让用户通过2FA屏幕.现在的问题是当部分登录成功时(验证码匹配)我将用户重定向到恢复URL并导致500错误页面(没有例外抛出或显示日志).如果在正常页面登录时发生这种情况,一切正常.

处理用户发布登录请求:

var messageId = clientIdentifier;

var claims = new List<Claim>();
(...)

var authenticationContext = new ExternalAuthenticationContext
{
    ExternalIdentity = new ExternalIdentity() { Provider = "API", Claims = claims },
};

await _userService.AuthenticateExternalAsync(authenticationContext);
var authResult = authenticationContext.AuthenticateResult;

var ctx = new PostAuthenticationContext
{ …
Run Code Online (Sandbox Code Playgroud)

c# two-factor-authentication asp.net-web-api identityserver3

23
推荐指数
1
解决办法
557
查看次数

IDX10803:无法创建以获取配置

我的配置有3个站点:Identity Server(Idp),Windows身份验证主机和我的最终用户客户端站点.在客户端站点上,我请求装饰的控制器[Authorize]和Identity Server启动.

端口44305上的Windows主机显然抛出异常并且身份服务器正在接收状态500.我可以毫无问题地访问Windows主机站点URL.我找回了一份XML文档

如何调试并找出停止此身份验证过程的异常或错误?我得到了一个3部分异常,内部最多如下

InvalidOperationException: IDX10803: Unable to create to obtain configuration from: 'https://localhost:44305/'.

Microsoft.IdentityModel.Protocols.ConfigurationManager`1.<GetConfigurationAsync>d__3.MoveNext() in ConfigurationManager.cs
Run Code Online (Sandbox Code Playgroud)

Windows Host OWIN启动使用UseWindowsAuthenticationService

Identity Server OWIN正在使用AuthenticationOptions = WsFederationAuthenticationOptions

var wsFederationOptions = new WsFederationAuthenticationOptions
            {
                AuthenticationType = "windows",
                Caption = "Windows",
                SignInAsAuthenticationType = signInAsType,
                MetadataAddress = "https://localhost:44305/",
                Wtrealm = "urn:idsrv3"
            };
            app.UseWsFederationAuthentication(wsFederationOptions);
        }
Run Code Online (Sandbox Code Playgroud)

以下是请求和回复

Request URL:https://localhost:44315/
Request Method:GET
Status Code:302 Found
Response:Location:https://localhost:16433/connect/authorize?client_id=hms2015&redirect_uri=...

Request: https://localhost:16433/connect/authorize?client_id=hms2015&redirect_uri=...
Request Method:GET
Status Code:302 Found
Location:https://localhost:16433/login?signin=fde7508a6634698847c3076c9028604b

Request URL:https://localhost:16433/login?signin=fde7508a6634698847c3076c9028604b
Request Method:GET
Status Code:500 Internal Server Error
Run Code Online (Sandbox Code Playgroud)

我没有可见的SSL问题.使用我的浏览器,我可以打开不同网站的所有页面,而不会发出任何警告.我将localhost IIS …

openid-connect identityserver3

21
推荐指数
4
解决办法
3万
查看次数

IdentityServer3绕过同意屏幕

当用户使用IdentityServer3登录时,我想绕过同意屏幕,默认情况下授予所有同意.有没有办法配置这个?

这是我想绕过的屏幕:

IdentityServer3授权权限屏幕

single-sign-on thinktecture-ident-server identityserver3

19
推荐指数
1
解决办法
2298
查看次数

我将如何生成Identity Server签名证书

在身份服务器示例中,我们找到了这样的代码 Startup.cs

var certFile = env.ApplicationBasePath + "\\idsrv3test.pfx";

var signingCertificate = new X509Certificate2(certFile, "idsrv3test");
Run Code Online (Sandbox Code Playgroud)

我如何在生产场景中更换它?

identityserver3 identityserver4

19
推荐指数
4
解决办法
1万
查看次数

跳过IdentityServer3登录屏幕

我们已将Client App配置为通过OpenID Connect协议使用IdentityServer3身份验证(它是使用OWIN中间件支持OIDC的ASP.NET MVC App).

IdentityServer3本身配置为使用本地登录和外部登录(例如Azure AD).

在常规流程中,一旦App需要对用户进行身份验证,它会将其重定向到IdentityServer3登录屏幕 - 这很好.但在某些情况下,基于每个请求,我想以某种方式绕过登录屏幕,让IdentityServer3知道用户想要立即登录特定的外部身份提供商.

这可能吗?

图片

openid thinktecture-ident-server openid-connect thinktecture identityserver3

16
推荐指数
2
解决办法
6421
查看次数

Identity Server未返回刷新令牌

我正在尝试设置Thinktecture的Identity Server 3,但在交换授权代码时(或使用ResourceOwner流时,我似乎无法让它返回刷新令牌,但我将专注于授权代码)因为它现在对我来说更重要).我回来访问令牌并且可以使用它们进行身份验证就好了,但它似乎甚至没有生成我期望回来的刷新令牌.为了让Identity Server返回刷新令牌,我需要做些什么特别的事情吗?

我查看了文档,但没有看到任何我设置错误的内容,并且他们在页面上唯一的刷新令牌,我没有做的是在发送用户时明确请求"offline_access"范围在那里进行身份验证,因为每当我尝试时,我都会收到"无效范围"错误.因此,我采用Thinktecture的措辞"请求offline_access范围(通过代码或资源所有者流程)"来表示offline_access范围是根据您正在使用的流程自动请求的内容.

我一直在努力跟踪他们的示例应用程序(以及Katana Project中现有的Owin中间件的源代码),我的设置如下:

  • 我使用他们的客户端类创建了一个客户端,手动指定以下内容:
    var client = new Client()
    {
        ClientId = "SomeId",
        ClientName = "Client with Authentication Code Flow",
        RequireConsent = false, //Setting this to true didn't help
        Flow = Flows.AuthorizationCode,
        ClientSecrets = new List() {
            new ClientSecret("secret")
        },
        RedirectUris = new List()
        {
            "localhost:/specific-redirect-path"
        }
    };
  • 我正在调用Authorization端点,如下所示:
    var authorizationEndpoint =
        AuthorizationEndpointBase +
        "?client_id=" + Uri.EscapeDataString(Options.ClientId) +
        "&scope=Default" +
        "&response_type=code" +
        "&redirect_uri=" + Uri.EscapeDataString(redirectUri) +
        "&state=" + Uri.EscapeDataString(state);
    Response.Redirect(authorizationEndpoint);
    其中"默认"是我创建的范围.
  • 在我的回调中,我按如下方式调用令牌端点: …

oauth-2.0 identityserver3

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

OWIN OpenIdConnect中间件IDX10311随机数无法验证

我有一个使用OWIN中间件的应用程序用于OpenIdConnect.startup.cs文件使用app.UseOpenIdConnectAuthentication的标准实现.cookie被设置为浏览器,但它出错:

IDX10311:RequireNonce为'true'(默认值),但validationContext.Nonce为null.nonce无法验证.如果您不需要检查nonce,请将OpenIdConnectProtocolValidator.RequireNonce设置为"false".

我发现当像大多数调试项目一样运行fiddler时,会发生这种情况.返回错误,但如果我返回该站点,一切正常,我的用户已通过身份验证.有没有人在运行提琴手时看到这种行为?

随着提琴手:

  • OpenIdConnect中的SecurityTokenValidated通知执行两次.
  • 第二次通过IDX10311后抛出错误
  • 浏览器包含有效的cookie,返回页面我可以查看有效的User.Identity数据.

没有提琴手跑:

  • SecurityTokenValidated在OpenIdConnect中执行一次
  • 没有抛出错误,继续加载控制器操作以进行后验证重定向Uri
  • Cookie也有效且User.Identity数据正确.

想法?我可以在不运行fiddler的情况下绕过它,但是在调试时,运行fiddler来检查流量也会很不错.

c# fiddler owin openid-connect identityserver3

15
推荐指数
4
解决办法
2万
查看次数