创建 OpenID Connect 提供程序(例如 AWS)时,我需要为连接器指定指纹。它是什么?我如何获得它?
例如,如何在不使用密钥的情况下将 GitHub 操作与 AWS 部署连接起来?
resource "aws_iam_openid_connect_provider" "github" {
url = "https://token.actions.githubusercontent.com"
client_id_list = [
"githubactions",
]
thumbprint_list = [
"6938fd4d98bab03faadb97b34396831e3780aea1",
]
}
Run Code Online (Sandbox Code Playgroud) 我正在根据Katana项目中的其他示例为OpenID Connect授权代码流编写自己的OWIN中间件.
作为其中的一部分,我必须构造一些URI,例如重定向URI和返回URL.
Katana中的其他示例通过连接当前请求中的部分来完成此操作,例如在CookieAuthenticationHandler中
loginUri =
Request.Scheme +
Uri.SchemeDelimiter +
Request.Host +
Request.PathBase +
Options.LoginPath +
new QueryString(Options.ReturnUrlParameter, currentUri);
Run Code Online (Sandbox Code Playgroud)
我的问题是什么规则管理两个路径属性中的最终结果:
OwinContext.Request.Path
OwinContext.Request.PathBase
Run Code Online (Sandbox Code Playgroud)
我已经尝试检查这些属性,因为请求通过下面管道中的不同处理程序,请求:
"https://localhost/Client/login" // Where Client is a virtual directory in IIS
Run Code Online (Sandbox Code Playgroud)
结果:
因此,如果不知道如何填充这些值的"规则",然后更改,则很难使用它们构造URI.如果有人能解释,将不胜感激.
我的配置的摘录是:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
LoginPath = new PathString("/Login")
});
app.UseQuillCodeFlowAuthentication(new QuillCodeFlowOptions());
app.Map("/login", map =>
{
map.Run(async ctx =>
{
if (ctx.Authentication.User == null ||
!ctx.Authentication.User.Identity.IsAuthenticated)
{
var authenticationProperties = new AuthenticationProperties();
[...] …Run Code Online (Sandbox Code Playgroud) 在我的实现中,我使用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中间件的类似的?有没有人有任何指针?
我建立一个连接处使用365个服务的多租户Web应用程序Microsoft.Owin.Security.OpenIdConnect,版本= 3.0.0.0和天青与Active Directory Microsoft.IdentityModel.Clients.ActiveDirectory,版本= 2.19.0.0下面这个样本.
我们的Web应用程序客户端(用户代理)使用asp.NET cookie对我们的服务器进行身份验证,而我们的服务器和授权服务器(此处为Azure AD)之间的身份验证是使用OpenID授权代码流进行的.
我们为Asp.NET cookie设置了30天的滑动到期时间.但是,即使设置了UseTokenLifetime = true,我们仍然有来自Authority Server的短暂的AuthenticationTicket,它应该与两个身份验证机制的生命周期相匹配.
我们遇到的问题是:我们的最终用户必须经常重新登陆(少于一小时).问题是,我们如何在这个owin openidconnect中间件中增加/更改身份验证票证的生命周期?
备注:我还发布了一个关于ADAL使用刷新令牌的问题.根据我们的理解,此问题仅与身份验证有关.作为ActiveDirectory客户端管理的授权问题的access_token和refresh_token的生存期与此问题无关.如果我错了,请纠正我.
Startup.Auth.cs
public partial class Startup
{
public const string CookieName = ".AspNet.MyName";
public const int DayExpireCookie = 30;
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
var cookieAuthenticationOptions = new CookieAuthenticationOptions()
{
CookieName = CookieName,
ExpireTimeSpan = TimeSpan.FromDays(DayExpireCookie),
AuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
SlidingExpiration = true,
};
app.UseCookieAuthentication(cookieAuthenticationOptions);
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = …Run Code Online (Sandbox Code Playgroud) 我想知道如何使用混合流刷新IdentityServer4客户端中的访问令牌,并使用ASP.NET Core MVC构建.
如果我已正确理解整个概念,则客户端首先需要具有"offline_access"范围,以便能够使用刷新令牌,这是启用短期访问令牌的最佳实践,并且能够撤消刷新令牌以防止任何新的访问令牌发给客户.
我成功获得了访问令牌和刷新令牌,但是我应该如何处理MVC客户端中访问令牌的实际更新过程?
OpenId Connect(OIDC)中间件可以自动处理吗?或者我应该通过基本检查访问令牌是否已过期或将很快到期(即将到来的30秒)来检查访问令牌的到期时间我通过基本检查访问令牌是否到期(即将到来的30秒)然后通过使用刷新令牌调用令牌端点来刷新访问令牌?
是否建议在Controller操作方法中使用IdentityModel2库TokenClient扩展RequestRefreshTokenAsync方法来调用令牌端点?
我已经看到OIDC中间件事件中的代码请求访问令牌并使用响应存储包含过期日期时间的声明.问题是我的OIDC已经以某种方式自动请求访问令牌,因此在收到第一个访问令牌后直接请求新的访问令牌感觉不太好.
没有访问令牌刷新逻辑的Controller操作方法示例:
public async Task<IActionResult> GetInvoices()
{
var token = await HttpContext.Authentication.GetTokenAsync("access_token");
var client = new HttpClient();
client.SetBearerToken(token);
var response = await client.GetStringAsync("http://localhost:5001/api/getInvoices");
ViewBag.Json = JArray.Parse(response).ToString();
return View();
}
Run Code Online (Sandbox Code Playgroud) 我一直在网上寻找答案,但找不到明确的答案。由于我不太了解 CSRF 攻击,并且stateOAuth 2.0 中的参数是为了避免这种攻击而制作的,我只是想知道是否state需要在客户端生成参数并将值放在本地存储或后端服务器上,然后将其存储到一个会话变量,然后我将其返回到客户端以创建我的 URL。第一个解决方案似乎是最好的,但它安全吗?
任何帮助是极大的赞赏。
我有一个 Web 应用程序,其中 Angular (7) 前端与服务器上的 REST API 通信,并使用 OpenId Connect (OIDC) 进行身份验证。我正在使用向我的 HTTP 请求HttpInterceptor添加Authorization标头以向服务器提供身份验证令牌。到现在为止还挺好。
但是,除了传统的 JSON 数据,我的后端还负责即时生成文档。在添加身份验证之前,我可以简单地链接到这些文档,如下所示:
<a href="https://my-server.com/my-api/document?id=3">Download</a>
Run Code Online (Sandbox Code Playgroud)
但是,现在我已经添加了身份验证,这不再有效,因为浏览器在获取文档时没有在请求中包含身份验证令牌 - 所以我401-Unathorized从服务器得到了响应。
因此,我不能再依赖普通的 HTML 链接——我需要创建自己的 HTTP 请求,并显式添加身份验证令牌。但是,我如何确保用户体验与用户单击链接时的体验相同?理想情况下,我希望使用服务器建议的文件名保存文件,而不是通用文件名。
我已经从 Keycloak 的 OIDC 端点中提取了用户的组信息,但它们没有随我定义的组 ATTRIBUTES 一起提供(请参阅组表单中的“属性”选项卡,靠近“设置”)。是否有权利要求添加到我的请求中?
我正在使用 RESTeasy 客户端访问 Keycloak 的管理 API(结果比使用提供的管理客户端好得多):
@Path("/admin/realms/{realm}")
public interface KeycloakAdminService {
@GET
@Path("/users/{id}/groups")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
List<GroupRepresentation> getUserGroups(@PathParam("realm") String realm, @PathParam("id") String userId,
@HeaderParam(AUTHORIZATION) String accessToken);
//DEBUG the access token must always be prefixed by "Bearer "
}
Run Code Online (Sandbox Code Playgroud)
所以我可以获取用户的组:
private void fetchUserGroups(UserInfoOIDC infos, String userId) {
log.info("Fetching user groups from {}...", getRealm());
try {
KeycloakAdminService proxy = kcTarget.proxy(KeycloakAdminService.class);
AccessTokenResponse response = authzClient.obtainAccessToken(getAdminUsername(), getAdminPassword());
List<GroupRepresentation> groups = proxy.getUserGroups(getRealm(), userId,
"Bearer " + response.getToken());
infos.importUserGroups(groups); //DEBUG …Run Code Online (Sandbox Code Playgroud) 我尝试使用授权代码和 Azure AD B2C(客户端的 oidc-client)为 Angular 应用程序设置身份验证,但我从 Angular 收到这些错误:
查看 B2C 审核日志后,我发现了以下错误消息:
客户在兑换机密授权时必须发送 client_secret。
这是我的客户端配置:
const settings = {
stsAuthority: 'https://supportodqqcdev.b2clogin.com/supportodqqcDev.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_SignUpSignInOdqPlatine',
clientId: '8447df5b-35a0-40a7-944f-5dcce87a2193',
clientRoot: 'https://localhost:4200',
scope: 'openid https://supportodqqcDev.onmicrosoft.com/platineclientdev/read',
};
this.userManager = new UserManager({
authority: settings.stsAuthority,
client_id: settings.clientId,
redirect_uri: `${settings.clientRoot}/signin-callback`,
scope: settings.scope,
response_type: 'code',
post_logout_redirect_uri: `${settings.clientRoot}/signout-callback`,
automaticSilentRenew: true,
silent_redirect_uri: `${settings.clientRoot}/assets/signin-silent-callback.html`,
});
Run Code Online (Sandbox Code Playgroud)
如果我将上述配置切换为使用本地 IdentityServer 实例,则一切正常。
有人能够指出我应该在哪里或如何调查这个问题吗?
一旦用户使用Dotnet Core MVC应用程序上的OpenID Connect进行身份验证,我试图找出运行某些代码的最佳方法.我不想在登录后对重定向URL进行硬编码,因为他们仍然需要在验证后尝试访问的地方结束.我只需要运行代码,例如."检查它是否第一次登录并设置标志"或类似的东西.
我使用的是中间件,但是因为每个请求都会调用它而导致一些问题.
有没有人对如何实现这一点有任何想法?
authentication asp.net-mvc openid-connect .net-core identityserver3
openid-connect ×10
asp.net-mvc ×3
owin ×3
angular ×2
oauth-2.0 ×2
.net-core ×1
adal ×1
auth-token ×1
azure-ad-b2c ×1
http-headers ×1
jwt ×1
katana ×1
office365 ×1
oidc-client ×1
resteasy ×1