zoukankan      html  css  js  c++  java
  • keycloak~11.3.0之后微信认证问题解决

    之前写过基于keycloak11.0.3版的微信认证的实现,而在升级到keycloak14.0.0之后,这个认证出现了问题,原因是因为人家keycloak内部源码又变了。

      AuthenticationSessionModel authSession = this.callback.getAndVerifyAuthenticationSession(state);
      session.getContext().setAuthenticationSession(authSession);
      federatedIdentity.setIdpConfig(getConfig());
      federatedIdentity.setIdp(AbstractOAuth2IdentityProvider.this);
      federatedIdentity.setAuthenticationSession(authSession);
    

    上面源代码的调整直接影响了我们的微信认证的集成,我们也需要进行调整Endpoint类中的authResponse方法,也相应的修改即可

     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);
     }
    

  • 相关阅读:
    java环境变量配置
    线性表基本操作(没实现)
    请求路径问题(视频学习)
    SpringMVC_关于<url-pattern>
    SpringMVC_第一个程序
    Spring与Web
    Spring与MyBatis整合上_Mapper动态代理方式
    Spring_Spring与DAO_Spring的事务管理
    Spring_Spring与DAO_Spring的Jdbc模板
    Spring_Spring与AOP_AspectJ基于XML的实现
  • 原文地址:https://www.cnblogs.com/lori/p/15499002.html
Copyright © 2011-2022 走看看