简体   繁体   English

使用 okta 身份验证打开身份验证自省

[英]open auth introspection with okta authentication

I am trying to introspect token recieved from okta inside .net core api, but keep getting "token is not active".我正在尝试反省从 .net 核心 api 内部的 okta 收到的令牌,但不断收到“令牌未激活”。 With the setup you see bellow I am able to retrieve identity from token.(basic okta auth schema)通过下面的设置,我可以从令牌中检索身份。(基本的 okta 身份验证模式)

service.AddAuthentication(options =>
  {
   options.DefaultAuthenticateScheme = OktaDefaults.ApiAuthenticationScheme;         
   options.DefaultChallengeScheme = OktaDefaults.ApiAuthenticationScheme;
   options.DefaultSignInScheme = OktaDefaults.ApiAuthenticationScheme;
   })
   .AddOktaWebApi(new OktaWebApiOptions()
   {
   OktaDomain = configuration["Authentication:Okta:OktaDomain"],
   AuthorizationServerId = configuration["Authentication:Okta:AuthorizationServerId"],
   Audience = configuration["Authentication:Okta:Audience"]});

But I need to set up authentication with "Introspection" schema here is my configuration:但我需要使用“内省”模式设置身份验证,这是我的配置:

service.AddAuthentication(auth =>     
    {
     auth.DefaultAuthenticateScheme = "Introspection";
       auth.DefaultChallengeScheme = "Introspection";
       auth.DefaultSignInScheme = "Introspection";
       })
       .AddOAuth2Introspection("Introspection", options =>
       {
       options.Authority = configuration["Authentication:Okta:Authority"];
       options.ClientId = configuration["Authentication:Okta:ClientId"];     
       options.TokenRetriever = request =>
    
       {
       string token = "";                
       if (request.Headers.ContainsKey("Authorization"))
       {                
        var parts = request.Headers["Authorization"].ToString().Split(" ");
        token = parts[1];
        return token;
       }
            if (request.Query.ContainsKey("access_token"))
            {
                token = request.Query["access_token"];
            }
            if (request.Cookies.ContainsKey("access_token"))
            {
                token = request.Cookies["access_token"];
            }
            return token;
        };
    });

Does anyone know what could be the reason?有谁知道可能是什么原因?

Okay, I`v found the problem but have no idea how to solve it for now, so the auth handler on back makes a request by wrong url, it does not specify default as query param.好的,我找到了问题,但现在不知道如何解决,所以后面的 auth 处理程序通过错误的 url 发出请求,它没有将默认值指定为查询参数。 It should be like this: https://domain/oauth2/default/v1/introspect But instead it looks like this: https://domain/oauth2/v1/introspect它应该是这样的:https://domain/oauth2/default/v1/introspect 但它看起来像这样:https://domain/oauth2/v1/introspect

I found the solution.我找到了解决方案。 There is a IntrospectionEndpoint property on IntrospectionOptions where you can specify full path including the authenticationServerID. IntrospectionOptions 上有一个IntrospectionEndpoint属性,您可以在其中指定包括 authenticationServerID 在内的完整路径。 Also need to add that for some authServer there no authServID at all and you can use authority where you just specifying domain( https://domain) and all the rest is done by introspectionHandler还需要补充一点,对于某些 authServer,根本没有 authServID,您可以使用仅指定域(https://domain)的权限,并且所有 rest 都由 introspectionHandler 完成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .net Okta 和 AWS 身份验证 - .net Okta and AWS authentication 开放式身份验证-提供程序 - Open Authentication - provider .NET内省与反思 - .NET Introspection VS Reflection 如何使用Windows身份验证和注册自定义身份验证管理器 - How to use windows authentication and register custom auth manager 基于角色的身份验证不适用于使用 JWT 身份验证开发的基于 Cookie 的身份验证 - Role based Auth not working with Cookie based Authentication being developed using JWT Auth 带有Open Id Connect和本地数据库的.net核心中的混合身份验证 - Hybrid authentication in .net core with Open Id Connect and local database 为什么Quickbooks API无法打开OAuth2身份验证的登录页面 - Why Quickbooks API is not able to open signin page for OAuth2 authentication 如何以编程方式从 Okta web API 检索 Okta SAML 令牌 - How to retrieve Okta SAML token from Okta web API programmatically 如何使用 .NET 中的 Hot Chocolate 扩展 GraphQL 内省类型 - How can I extend the GraphQL introspection types with Hot Chocolate in .NET 使用IdentityServer4中的offline_access范围对令牌进行自省 - Introspection of token using offline_access scope in identityserver4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM