我有一个场景,一组用户只能通过第三方登录进行身份验证。是否可以传递一个额外的参数来跳过登录页面并自动将用户重定向到第 3 方登录页面并避免按下第 3 方的按钮?
我正在Identity Server 3中实现AuthorizationCode流程.
当我登录时,我得到一个invalid_scope例外.
这是我的客户:
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
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的创业公司:
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = UrlManager.AuthenticationService + "identity",
ClientId = "webapplication",
Scope = "openid profile offline_access",
ResponseType = "code",
RedirectUri = UrlManager.WebApplication, …Run Code Online (Sandbox Code Playgroud) 我正在将身份验证过程转换为支持异步,VS 2015 IDE 警告我以下消息: 异步方法缺少“等待”运算符并将同步运行...等等...
不管怎样,代码连接到 LDAP 存储并验证用户的帐户等等...我已经尝试过使用 wait 进行各种操作,但我只是在这里遗漏了一些东西。我将代码恢复到之前的状态。我将不胜感激任何有关使其正确支持异步的指导...
这是代码:
public async Task<User> GetAsyncADUser(PrincipalContextParameter param)
{
try
{
if (UseLDAPForIdentityServer3)
{
using (var pc = new PrincipalContext(ContextType.Domain, param.ADDomain, param.ADServerContainer, param.ADServerUser, param.ADServerUserPwd))
{
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(pc, param.UserNameToValidate);
if (userPrincipal != null)
{
bool isvalid = pc.ValidateCredentials(userPrincipal.DistinguishedName, param.UserPasswordToValidate, ContextOptions.SimpleBind);
if (isvalid)
{
User user = new User { ad_guid = userPrincipal.Guid.ToString(), Username = param.UserNameToValidate, Password = param.UserPasswordToValidate };
return user;
}
}
}
}
}
catch (Exception ex)
{ …Run Code Online (Sandbox Code Playgroud) 我是Identity Server的新手,所以请耐心等待.尝试了解Identity Server 4中的以下两个库.
IdentityServer4.EntityFramework IdentityServer4.AspNetIdentity
据我所知,这有助于EF和AspNet.查看源代码和实体,它们都有完全不同的实体.AspNetIdentity有与User,Roles等相关的实体,而EntityFramework则包括Client,Resources等.但是两者都有UserClaim让我有点困惑.是否可以在项目中使用这两个库?或者只应该使用或其他?
如果我们可以使用两者,那么我们可以对两个库中的UserClaim实体做些什么呢?
谢谢,
c# entity-framework asp.net-identity identityserver3 identityserver4
我在启动 IdentityServer 3 时遇到问题。这是一个非常简单的设置,我打算将它用于开发环境,但我在诊断问题时遇到了问题。这是我的代码:
启动文件
using Owin;
using System;
using System.Security.Cryptography.X509Certificates;
using IdentityServer3.Core.Models;
using IdentityServer3.Core.Configuration;
namespace IdentityServer3
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Map("/identity", idsrvApp =>
{
idsrvApp.UseIdentityServer(new IdentityServerOptions
{
SiteName = "Embedded IdentityServer",
SigningCertificate = LoadCertificate(),
Factory = new IdentityServerServiceFactory()
.UseInMemoryUsers(Users.Get())
.UseInMemoryClients(Clients.Get())
.UseInMemoryScopes(StandardScopes.All)
});
});
}
X509Certificate2 LoadCertificate()
{
return new X509Certificate2(
string.Format(@"{0}bin\idsrv3test.pfx", AppDomain.CurrentDomain.BaseDirectory), "idsrv3test");
}
}
}
Run Code Online (Sandbox Code Playgroud)
用户.cs
using IdentityServer3.Core;
using IdentityServer3.Core.Services.InMemory;
using System.Collections.Generic;
using System.Security.Claims;
namespace IdentityServer3
{
public static class Users
{ …Run Code Online (Sandbox Code Playgroud) 在 ASP.NET MVC 应用程序中,我正在尝试针对外部 OIDC 服务实施身份验证。对于我的测试,我使用IdentityServer3 ( https://identityserver.github.io/Documentation/ ) 和公共 OIDC 演示服务器:https ://mitreid.org/
我从 GitHub 克隆了这个示例:https : //github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/MVC%20Authentication
然后添加以下代码将公共 OIDC 服务器注册为外部登录提供程序:
private void ConfigureIdentityProviders(IAppBuilder app, string signInAsType)
{
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "<AuthTypeName>",
Authority = "https://mitreid.org/",
Caption = "MIT Test Server",
ClientId = "<Client Id>",
ClientSecret = "<Client Secret>",
RedirectUri = "https://localhost:44319/", //NOT SURE WHAT TO PUT HERE
ResponseType = "code",
Scope = "openid email profile",
SignInAsAuthenticationType = signInAsType
});
}
Run Code Online (Sandbox Code Playgroud)
代码有效,我可以选择通过外部 OIDC 服务器登录。浏览器重定向到外部服务器登录页面,当输入登录名和密码时,将显示同意页面。但是,在浏览器导航回 …