我们有一个ASP.NET MVC应用程序,在没有针对IdentityServer3的问题的情况下进行身份验证,但是如果用户在大约3分钟后继续使用AJAX功能之前等待使用ApiController的应用程序的Web API部分开始失败(3分钟之前一切似乎都很好) .
Chrome中出现的错误包括:
XMLHttpRequest无法加载 https://test-auth.myauthapp.com/auth/connect/authorize?client_id=ecan-farmda ... gwLTk5ZjMtN2QxZjUyMjgxNGE4MDg2NjFhZTAtOTEzNi00MDE3LTkzNGQtNTc5ODAzZTE1Mzgw.请求的资源上不存在"Access-Control-Allow-Origin"标头.因此,不允许来源" http://test.myapp.com "访问.
在IE上我收到以下错误:
SCRIPT7002:XMLHttpRequest:网络错误0x4c7,操作被用户取消.
看看IdentityServer3的日志,我看到的条目如下:
2015-08-10 16:42 [警告](Thinktecture.IdentityServer.Core.Configuration.Hosting.CorsPolicyProvider)对路径的CORS请求:/ connect/authorize from origin:http://test.myapp.com 但拒绝因为无效CORS路径
在IdentityServer3 Web应用程序中,我向客户提供AllowedCorsOrigins:
Thinktecture.IdentityServer.Core.Models.Client client = new Thinktecture.IdentityServer.Core.Models.Client()
{
Enabled = configClient.Enabled,
ClientId = configClient.Id,
ClientName = configClient.Name,
RedirectUris = new List<string>(),
PostLogoutRedirectUris = new List<string>(),
AllowedCorsOrigins = new List<string>(),
RequireConsent = false, // Don't show consents screen to user
RefreshTokenExpiration = Thinktecture.IdentityServer.Core.Models.TokenExpiration.Sliding
};
foreach (Configuration.RegisteredUri uri in configClient.RedirectUris)
{
client.RedirectUris.Add(uri.Uri);
}
foreach (Configuration.RegisteredUri uri in configClient.PostLogoutRedirectUris)
{ …Run Code Online (Sandbox Code Playgroud) 我正在编写ASP.Net核心Web应用程序并使用UseOpenIdConnectAuthentication它将其连接到IdentityServer3.模拟他们的ASP.Net MVC 5样本我正在尝试转换从Identity Server收到的声明,以删除" 当然不需要的低级协议声明 ".在MVC 5中,他们为SecurityTokenValidated Notification添加了一个处理程序,该处理程序AuthenticationTicket仅使用所需的声明来交换一个.
在ASP.Net Core中,为了做同等的事情,我认为我需要处理OnTokenValidated中OpenIdConnectEvents.但是,在该阶段,似乎没有检索到附加范围信息.如果我处理OnUserInformationReceived,则存在额外信息,但存储在用户而不是主体上.
在身份验证完成后,其他事件似乎都不是永久删除我不想保留的声明的明显位置.任何建议都感激不尽!
如何在Thinktecture IdentityServer v3中启用日志记录?
我目前正在收到一个通用的错误页面,说"出现意外错误".
我能够弄清楚通常的错误会被返回,ErrorPageFilterAttribute这似乎解决了一些ILog记录我所追求的细节的实现.
我怀疑它是一些具体的实现ILog需要以某种方式配置.
在我的实现中,我使用OpenID-Connect服务器(Identity Server v3 +)来验证Asp.net MVC 5应用程序(使用AngularJS前端)
我打算使用OID代码流(使用Scope Open_ID)来验证客户端(RP).对于OpenID连接中间件,我使用的是OWIN(Katana Project)组件.
实施前,我想明白了反向信道令牌请求,刷新令牌请求处理等使用OWIN.但我无法找到这种类型的实现(大多数可用的示例使用隐式流)的任何文件.
我可以在这里找到ID Server v3的通用代码流实现的示例https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source
我正在寻找一个使用OWIN中间件的类似的?有没有人有任何指针?
我配置了Identity Server:
public void Configuration(IAppBuilder app)
{
var factory = new IdentityServerServiceFactory().UseInMemoryClients(new Client[] {
new Client()
{
ClientName = "MyClient",
ClientId = "MyClientId",
Enabled = true,
Flow = Flows.Implicit,
RedirectUris = new List<string> { "MyClientServer/callback" },
};
});
}
Run Code Online (Sandbox Code Playgroud)
和客户端服务器:
public void Configuration(IAppBuilder app)
{
var cookieOptions = new CookieAuthenticationOptions();
cookieOptions.AuthenticationType = "Cookies";
app.UseCookieAuthentication(cookieOptions);
var authenticationOptions = new OpenIdConnectAuthenticationOptions() {
Authority = "https://MyIdentityServer/core",
ClientId = "MyClientId",
SignInAsAuthenticationType = "Cookies",
UseTokenLifetime = true,
RedirectUri = "MyClientServer/callback"
});
app.UseOpenIdConnectAuthentication(authenticationOptions);
}
Run Code Online (Sandbox Code Playgroud)
当用户使用"记住我"选项登录时,身份cookie已过期日期:
idsvr.session …Run Code Online (Sandbox Code Playgroud) cookies session-cookies katana asp.net-identity identityserver3
我正在尝试使用公钥/私钥而不是IdentityServer4的客户机密的共享密钥.这种方法记录在这里.
如果它是共享密钥,则请求将包含secret纯文本.例如
curl -X POST \
http://<identityserver>/connect/token \
-F client_id=abc \
-F client_secret=secret \
-F grant_type=client_credentials \
-F scope=api1 api2
Run Code Online (Sandbox Code Playgroud)
我的问题是:secret使用公钥/私钥认证方法应该传递什么?
为了给出一些背景知识,使用公共/密钥身份验证的客户端将使用以下步骤向IdentityServer 注册
客户端生成.crt文件,例如
// create key
$ openssl genrsa -des3 -passout pass:x -out client.pass.key 2048
$ openssl rsa -passin pass:x -in client.pass.key -out client.key
// create certificate request (csr)
$ openssl req -new -key client.key -out client.csr
// create certificate (crt)
$ openssl x509 -req -sha256 -days 365 -in client.csr -signkey …Run Code Online (Sandbox Code Playgroud)我使用了IdentityServer v3,现在我希望一个网站既是身份主机又是web api主机.
权限选项不用于验证令牌.我已经验证了令牌端点,并且令牌验证端点正在按预期工作(我可以使用邮递员获取并验证令牌).我使用[Authorize]属性来装饰我的控制器方法.在IdentityServer上启用了完整日志记录,在使用标题名称"Authorization"创建api请求时,没有记录任何内容,其值为"Bearer mytokenhere".
这是使用Visual Studio 2015 CTP6的ASP.NET 5上的vNext网站.
app.UseMvc();
var certFile = AppDomain.CurrentDomain.BaseDirectory + "\\myawesomesite.pfx";
app.Map("/core", core =>
{
var factory = InMemoryFactory.Create(
users: Users.Get(),
clients: Clients.Get(),
scopes: Scopes.Get());
var idsrvOptions = new IdentityServerOptions
{
SiteName = "Lektieplan",
Factory = factory,
RequireSsl = false,
SigningCertificate = new X509Certificate2(certFile, "lektieplan"),
CorsPolicy = CorsPolicy.AllowAll,
LoggingOptions = new LoggingOptions { EnableWebApiDiagnostics = true,EnableHttpLogging = true, IncludeSensitiveDataInLogs = true, WebApiDiagnosticsIsVerbose = true }
};
core.UseIdentityServer(idsrvOptions);
});
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = "http://localhost:57540/core", …Run Code Online (Sandbox Code Playgroud) 我收到错误'客户端应用程序未知或未经授权.访问我的网站的受保护区域时.
这是我的客户:
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) 我没有准确了解NSwag如何与IdentityServerX承载令牌进行交互并按常规添加请求标头?我的主机api应用程序使用LDAP身份验证实现IdentityServer3,据我了解; 如果任何主机需要一个令牌进行身份验证,那么任何客户端都必须在请求头上发送它.那么我如何在为NSwag客户工作时处理它呢?
任何想法都赞赏.谢谢.
我正在尝试创建一个主从类型配置以使用 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
identityserver3 ×10
oauth-2.0 ×3
asp.net-core ×2
asp.net-mvc ×2
c# ×2
owin ×2
.net ×1
ajax ×1
asp.net ×1
cookies ×1
cors ×1
federation ×1
katana ×1
nswag ×1
oauth ×1