Json 无法使用pac4j获取使用CAS服务器的通用OAuth2客户端

Json 无法使用pac4j获取使用CAS服务器的通用OAuth2客户端,json,oauth-2.0,instagram-api,cas,apereo,Json,Oauth 2.0,Instagram Api,Cas,Apereo,我正在致力于在CAS服务器中使用委托身份验证将登录与Instagram集成。我已经在cas.properties文件中配置了所有必需的属性,并为其创建了一个服务注册JSON文件。当我登录Instagram帐户时,我被重定向回CAS登录页面,但什么也没发生 我尝试使用ServiceRegistryJSON文件以及cas.properties中的不同属性进行实验 cas.properties文件包含以下内容 cas.authn.pac4j.oauth2[0].id={client_id} cas.a

我正在致力于在CAS服务器中使用委托身份验证将登录与Instagram集成。我已经在cas.properties文件中配置了所有必需的属性,并为其创建了一个服务注册JSON文件。当我登录Instagram帐户时,我被重定向回CAS登录页面,但什么也没发生

我尝试使用ServiceRegistryJSON文件以及cas.properties中的不同属性进行实验

cas.properties文件包含以下内容

cas.authn.pac4j.oauth2[0].id={client_id}
cas.authn.pac4j.oauth2[0].secret={client_secret}
cas.authn.pac4j.oauth2[0].authUrl=https://api.instagram.com/oauth/authorize?client_id={client_id}&response_type=code&client_name=instagram
cas.authn.pac4j.oauth2[0].tokenUrl=https://api.instagram.com/oauth/access_token?grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}&client_name=instagram
cas.authn.pac4j.oauth2[0].profileUrl=https://api.instagram.com/v1
cas.authn.pac4j.oauth2[0].clientName=instagram
cas.authn.pac4j.oauth2[0].profileVerb=GET
cas.authn.pac4j.oauth2[0].profilePath=/users/self/

cas.serviceRegistry.watcherEnabled=true
cas.serviceRegistry.schedule.repeatInterval=10000
cas.serviceRegistry.schedule.startDelay=15000

cas.serviceRegistry.initFromJson=true

cas.serviceRegistry.json.location=file:/etc/cas/services/
服务JSON文件如下所示:

{
  "@class" : "org.jasig.cas.services.RegexRegisteredService",
  "serviceId" : "^https://.*.{domain}.com.*",
  "name" : "eyerne",
  "id" : 10002,
  "description" : "This service definition authorizes the eyerne URL.",
  "accessStrategy" : {
    "@class" : "org.jasig.cas.services.DefaultRegisteredServiceAccessStrategy",
    "enabled" : true,
    "ssoEnabled" : true
  },
  "bypassApprovalPrompt": true,
  "generateRefreshToken": true,
  "proxyPolicy" : {
    "@class" : "org.apereo.cas.services.RegexMatchingRegisteredServiceProxyPolicy",
    "pattern" : "^https?://.*"
  },
  "supportedGrantTypes": [ "java.util.HashSet", [ "authorization_code", "client_credential"] ],
  "supportedResponseTypes": [ "java.util.HashSet", [ "code", "token" ] ],
  "attributeReleasePolicy" : {
    "@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"
  }
}
我无法达到CAS能够使用配置文件URL获取访问令牌和获取用户详细信息的程度

相反,我得到以下错误:

DEBUG [org.apereo.cas.support.oauth.services.OAuth20AuthenticationServiceSelectionStrategy] - <Authentication request is not identified as an OAuth request>

=============================================================
WHO: audit:unknown
WHAT: [event=success,timestamp=Mon Aug 05 16:27:34 IST 2019,source=RankedAuthenticationProviderWebflowEventResolver]
ACTION: AUTHENTICATION_EVENT_TRIGGERED
APPLICATION: CAS
WHEN: Mon Aug 05 16:27:34 IST 2019
CLIENT IP ADDRESS: 0:0:0:0:0:0:0:1
SERVER IP ADDRESS: 0:0:0:0:0:0:0:1
=============================================================
为了能够使用Instagram将用户成功登录到CAS服务器,我需要做更多或更改什么

更新日期:2019年8月16日 我通过修补Instagram的一个模块,使PAC4J能够为Instagram工作。我必须手动将访问令牌添加到被调用的最终配置文件url中,并将身份验证方法从basicAuth更改为requestBody

然而,现在当Instagram将我重定向回CAS服务器时,在登录后,我应该被重定向到服务URL。相反,我被重定向到CAS登录成功页面,并显示以下消息:

您,tridhya123,已成功登录到中央计算机 身份验证服务。但是,您看到此页面是因为CAS 不知道您的目标目的地以及如何到达目的地。 再次检查身份验证请求并确保目标 在CAS授权和注册的服务/应用程序是 指定的

以下是调试日志文件,显示了从Instagram到CAS的登录流程:


您想在登录页面中,单击一个按钮,转到
Instagram
,然后返回并成功登录,例如,正确吗?或者您想使用
OAuth
登录流吗。您现在通过同时使用
服务
cas.properties
来应用这两种方法,但不确定您真正想要的是什么。@NgSekLong-我明白您的意思了。我说的是使用泛型OAuth2.0进行委托身份验证。@NgSekLong-但是,我能够部分解决这个问题。我不得不修改pac4j,因为我不得不将身份验证方法从basicAuth更改为requestBody,而且在调用配置文件URL时,访问令牌参数没有被追加。现在,我面临的问题是,在登录后,我将被带到CAS中的登录成功页面,而不是使用service Ticket重定向到service URL,只是询问是否指定了
service
参数?e、 g.
https://www.mycas.com/cas/login?service=https://www.placetogo.com
是的,我确实以同样的方式指定了。如果看到网络监视器报告,/clientredirect url不包含服务url。此url在整个过程中自动使用2次。我不确定这是否是原因。您想在登录页面中,单击一个按钮,转到
Instagram
,然后返回并成功登录,例如,正确吗?或者您想使用
OAuth
登录流吗。您现在通过同时使用
服务
cas.properties
来应用这两种方法,但不确定您真正想要的是什么。@NgSekLong-我明白您的意思了。我说的是使用泛型OAuth2.0进行委托身份验证。@NgSekLong-但是,我能够部分解决这个问题。我不得不修改pac4j,因为我不得不将身份验证方法从basicAuth更改为requestBody,而且在调用配置文件URL时,访问令牌参数没有被追加。现在,我面临的问题是,在登录后,我将被带到CAS中的登录成功页面,而不是使用service Ticket重定向到service URL,只是询问是否指定了
service
参数?e、 g.
https://www.mycas.com/cas/login?service=https://www.placetogo.com
是的,我确实以同样的方式指定了。如果看到网络监视器报告,/clientredirect url不包含服务url。此url在整个过程中自动使用2次。我不确定这是否是原因。
CAS is unable to process this request: "500:Internal Server Error"

org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing org.apereo.cas.web.flow.DelegatedClientAuthenticationAction@33ec9d9 in state 'clientAction' of flow 'login' -- action execution attributes were 'map[[empty]]'