0

我已经按照https://wiki.jasig.org/display/CASUM/Configuration+for+the+OAuth+上的 Jasig CAS Wiki 中的说明成功配置了我的 CAS v. 3.5.2 以使用 OAuth 1.0 将身份验证委托给 Yahoo client+support+in+CAS+server+version+%3E%3D+3.5.1 现在,我正在尝试使用 OAuth 2.0 添加与 Google 的身份验证。为此,我通过将 scribe-up 的依赖更新到 1.3.1 来使用 Google2Provider。但是访问 CAS 登录页面时会抛出以下错误:

SEVERE: Servlet.service() for servlet [cas] in context with path [/cas] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing org.jasig.cas.support.oauth.web.flow.OAuthAction@4d88f286 in state 'oauthAction' of flow 'login' -- action execution attributes were 'map[[empty]]'] with root cause
java.lang.IllegalArgumentException: Cannot encode null object
at org.scribe.utils.Preconditions.check(Preconditions.java:82)
at org.scribe.utils.Preconditions.checkNotNull(Preconditions.java:29)
at org.scribe.utils.OAuthEncoder.encode(OAuthEncoder.java:28)
at org.scribe.up.addon_to_scribe.GoogleApi20.getAuthorizationUrl(GoogleApi20.java:36)
at org.scribe.oauth.OAuth20ServiceImpl.getAuthorizationUrl(OAuth20ServiceImpl.java:69)
at org.scribe.up.provider.BaseOAuth20Provider.getAuthorizationUrl(BaseOAuth20Provider.java:43)
at org.jasig.cas.support.oauth.web.flow.OAuthAction.doExecute(OAuthAction.java:128)

...

似乎异常是由 GoogleApi20.getAuthorizationUrl(final OAuthConfig config) 中的配置参数的空“范围”引起的,其中 config.getScope() 返回空:

public String getAuthorizationUrl(final OAuthConfig config) {
    return String.format(AUTHORIZATION_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()),
                         OAuthEncoder.encode(config.getScope()));
} 

那么是否有可能通过在 CAS 中同时使用 OAuth 1.0 向 Yahoo 进行身份验证和使用 OAuth 2.0 向 Google 进行身份验证来实现这一点?有没有一个例子说明这是如何完成的?

先感谢您。

4

1 回答 1

1

我是 CAS 中 OAuth 客户端支持的创建者。事实上,在Google2Provider中有一个错误:默认范围为空。使用适当的设置器设置实际范围:setScope(final Google2Scope scope)解决问题...

于 2013-07-06T18:39:56.667 回答