使用Google OAuth 2.0和使用Yahoo OAuth 1.0的CAS OAuth身份验证 [英] CAS OAuth Authentication Using Google OAuth 2.0 and Using Yahoo OAuth 1.0

查看:199
本文介绍了使用Google OAuth 2.0和使用Yahoo OAuth 1.0的CAS OAuth身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照 https://wiki.jasig.org/display/CASUM/Configuration+ for + the + OAuth + client + support + in + CAS + server + version +%3E%3D + 3.5.1
现在,我正在尝试使用OAuth 2.0向Google添加身份验证。为此,我通过将对记述的依赖更新为1.3.1来使用Google2Provider。但是访问CAS登录页面时会引发以下错误:

I've successfully configured my CAS v. 3.5.2 to delegate authentication to Yahoo using OAuth 1.0 by following the instruction Jasig CAS Wiki at https://wiki.jasig.org/display/CASUM/Configuration+for+the+OAuth+client+support+in+CAS+server+version+%3E%3D+3.5.1 Now, I am trying to add the authentication with Google using OAuth 2.0. For that, I am using Google2Provider by updating the dependency on scribe-up to 1.3.1. But the following error is thrown upon accessing CAS login page:

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)

...

似乎ption是由GoogleApi20.getAuthorizationUrl(final OAuthConfig config)中config参数的空范围引起的,其中config.getScope()返回null:

It appears the exception is caused by a null "scope" of the config parameter in GoogleApi20.getAuthorizationUrl(final OAuthConfig config) where config.getScope() returns null:

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

因此可以通过使用OAuth 1.0与Yahoo进行身份验证来使其工作并与Google在CAS中同时使用OAuth 2.0?有一个示例显示了如何完成此操作吗?

So is it possible to get this to work by authenticating with Yahoo using OAuth 1.0 and with Google using OAuth 2.0 at the same time in CAS? Is there an example that shows how this is done?

预先感谢您。

推荐答案

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

I'm the creator of the OAuth client support in CAS. In fact, there was a bug in the Google2Provider : the default scope is null. Set a real scope using the appropriate setter : setScope(final Google2Scope scope) to fix the problem...

这篇关于使用Google OAuth 2.0和使用Yahoo OAuth 1.0的CAS OAuth身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆