中文字幕精品亚洲无线码二区,国产黄a三级三级三级看三级,亚洲七七久久桃花影院,丰满少妇被猛烈进入,国产小视频在线观看网站

keycloak~11.3.0之后微(wei)信(xin)認證問(wen)題解決

之前寫過基于keycloak11.0.3版的微信認證的實(shi)現,而在升級到keycloak14.0.0之后,這個認(ren)證出現了問題,原因是因為人家(jia)keycloak內部源(yuan)碼(ma)又變(bian)了。

  • 影響類文件 server-spi-private/src/main/java/org/keycloak/broker/provider/BrokeredIdentityContext.java
  • github地址:
  • 修改的地方:去掉了code字段,相應的setCode,getCode也去了,在認證后回調的地方也進行了調整
  AuthenticationSessionModel authSession = this.callback.getAndVerifyAuthenticationSession(state);
  session.getContext().setAuthenticationSession(authSession);
  federatedIdentity.setIdpConfig(getConfig());
  federatedIdentity.setIdp(AbstractOAuth2IdentityProvider.this);
  federatedIdentity.setAuthenticationSession(authSession);

上面源代碼的調整直接影響了我們的微信認證的集成,我們也需要進行調整Endpoint類中的authResponse方(fang)法(fa),也相應的修改即(ji)可

 BrokeredIdentityContext federatedIdentity = null;
 if (authorizationCode != null) {
    String response = generateTokenRequest(authorizationCode, wechatFlag).asString();
    logger.info("authResponse.response=" + response);
    federatedIdentity = getFederatedIdentity(response, wechatFlag);

    if (getConfig().isStoreToken()) {
      if (federatedIdentity.getToken() == null)
        federatedIdentity.setToken(response);
    }
    federatedIdentity.setIdpConfig(getConfig());
    federatedIdentity.setIdp(WeiXinIdentityProvider.this);
    //11.3.0之后改成這樣了,去掉了code字段
    AuthenticationSessionModel authSession = this.callback.getAndVerifyAuthenticationSession(state);
    session.getContext().setAuthenticationSession(authSession);
    federatedIdentity.setAuthenticationSession(authSession);
    logger.info("authResponse success" + federatedIdentity);
    return callback.authenticated(federatedIdentity);
 }
posted @ 2021-11-02 14:56  張占嶺  閱讀(537)  評論(0)    收藏  舉報