如何访问cfoauth返回的结果结构?

问题描述 投票:0回答:1

我正在使用 Coldfusion 2021 和 Okta。 我的登录页面成功重定向到我可以登录的 Okta 登录名。当我重定向回我的重定向时,我会遇到两个问题之一,具体取决于我的设置方式。

当重定向URI 与包含 cfoauth 标记的页面相同时,就会出现第一个问题。代码如下:

登录.cfm

<cfoauth 
   clientid="xxxxxxxxxxx" scope="openid profile" authendpoint="https://loginurl/oauth2/authorize" 
   secretkey="xxxxxxxxxxx" state="test" accesstokenendpoint="https://mydomain/accesstoken.cfm" 
   redirecturi="https://mydomain/login.cfm" result="res">

<cfscript>
   session.auth= res;
   writeDump(session);
<cfscript>

在这种情况下,我收到以下错误:

Failure! Ensure that you have provided valid data for attributes.
查看服务器上的异常日志,除了 cfoauth 标记的行号之外,没有提供任何额外信息。

当重定向URI 与包含 cfoauth 调用的页面不同时,就会出现第二个问题。 本例代码如下:

登录.cfm

<cfoauth 
   clientid="xxxxxxxxxxx" scope="openid profile" authendpoint="https://loginurl/oauth2/authorize" 
   secretkey="xxxxxxxxxxx" state="test" accesstokenendpoint="https://mydomain/accesstoken.cfm" 
   redirecturi="https://mydomain/index.cfm" result="res">

<cfscript>
   session.auth= res;
<cfscript>

index.cfm


<cfscript>
   writeDump(session);
</cfscript>

我无法查看或编辑 Okta 方面的内容,因此我无法在此处提供该信息,但我假设它已正确配置,因为我可以登录,并且它按预期将我重定向回重定向。 该文档似乎向我表明,redirecturi 应该是具有标签的同一页面,但无论哪种情况,我都不确定出了什么问题。

oauth coldfusion okta coldfusion-2021
1个回答
0
投票

我最终解决了这个问题,所以如果有人需要它,我的问题是我的访问令牌端点。 就我而言,我通过使用以下 cfoauth 标签解决了这个问题。 这需要是 Okta 提供的访问令牌端点,并将重定向uri 设置为包含 cfoauth 标签的同一 uri。

<cfoauth clientid="xxxxxxxxxxx" scope="openid profile" authendpoint="https://loginurl/oauth2/authorize" secretkey="xxxxxxxxxxx" state="test" accesstokenendpoint="https://loginurl/oauth2/authorize" redirecturi="https://mydomain/login.cfm" result="res">
© www.soinside.com 2019 - 2024. All rights reserved.