小编eol*_*son的帖子

RequestEnhancer not used for AuthorizationCodeAccessTokenProvider during getRedirectForAuthorization

What I'm trying to do is to add an extra parameter openid.realm to my authorization request.

My problem is very similar to https://github.com/spring-projects/spring-security-oauth/issues/123 and I tried to follow the outlined to way solve it:

// Create an enhancer that adds openid.realm
DefaultRequestEnhancer enhancer = new DefaultRequestEnhancer();
enhancer.setParameterIncludes(Arrays.asList("openid.realm"));

// Create tokenprovider that use the enhancer
AuthorizationCodeAccessTokenProvider tokenProvider =
    new AuthorizationCodeAccessTokenProvider();
tokenProvider.setAuthorizationRequestEnhancer(enhancer);

// Give the tokenProvider to the rest template
googleOauthRestTemplate.setAccessTokenProvider(tokenProvider);
googleOauthRestTemplate.
    getOAuth2ClientContext().
        getAccessTokenRequest().set("openid.realm", "http://localhost:8080/");

// Try to get the protected resource …
Run Code Online (Sandbox Code Playgroud)

spring-security spring-security-oauth2

5
推荐指数
0
解决办法
882
查看次数

什么规则管理内联jslint指令

我试图保持jslint排除尽可能接近错误,以免错误地隐藏任何错误.示例中未使用的参数在x函数中f2,我只想排除这种情况.

第一个示例,不包括周围的函数,但会隐藏其他错误,如果有的话:

/*jslint unparam: true*/
function test1() {
    var f1 = function (x) {
            alert(x);
        },
        f2 = function (x) {};

    f1(0);
    f2(0);
}
/*jslint unparam: false*/
Run Code Online (Sandbox Code Playgroud)

围绕var语句也有效,但会隐藏错误f1:

function test2() {
    /*jslint unparam: true*/
    var f1 = function (x) {
            alert(x);
        },
        f2 = function (x) {};
    /*jslint unparam: false*/

    f1(0);
    f2(0);
}
Run Code Online (Sandbox Code Playgroud)

这个产生一个错误:"预期一个标识符,而是看到'/*jslint'(一个保留字)."

function test3() {
    var f1 = function (x) {
            alert(x);
        },
        /*jslint unparam: true*/
        f2 = function (x) {};
        /*jslint …
Run Code Online (Sandbox Code Playgroud)

javascript jslint

4
推荐指数
1
解决办法
1807
查看次数