2

keycloak~11.3.0之后微信认证问题解决

 2 years ago
source link: https://www.cnblogs.com/lori/p/15499002.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

Recommend

  • 7

    上一篇文章简单介绍了Keycloak,反响不错。看来大家都对这个东西感兴趣,今天就来进一步的体验Keycloak,...

  • 15

    Github使用新的token认证机制导致push失败问题解决Github push推东西的时候突然报错了,一查发现是换了认证方式的原因,之前输入密码push,现在得改用token了,但是网上重置仓库密码啥的试了push都还是失败...

  • 5

    使用REST API与KEYCLOAK进行OUATH2协议的登录认证 如果要访问受KEYCLOAK保护的REST API服务,则需要夹带一个ACCESS_TOKEN。前端页面:...

  • 1

    keycloak~KEYCLOAK_REMEMBER_ME中文用户名问题新版已经解决 - 张占岭 - 博客园 敢于对过去告一个段落,才有信心掀开新的篇章! 关注:架构设计、领域驱动、统一认证、微服...

  • 7
    • www.cnblogs.com 2 years ago
    • Cache

    keycloak~自定义directgrant直接认证

    keycloak~自定义directgrant直接认证 direct grant我们把它理解为通过rest接口直接认证,这...

  • 7
    • blog.didispace.com 2 years ago
    • Cache

    换M1芯片之后,IDEA很卡的问题解决

    最近,我花了两周的时间,给大家整理了一波最新的面经。内容包含BAT、字节等一众大厂的真实面试经历的分享,点击这里赶紧领取吧!

  • 7
    • lovedesign.is-programmer.com 2 years ago
    • Cache

    YC认证最后一步转圈问题解决

    PI NetWork Introduction Pi Network由斯坦福大学尼古拉斯博士带领技术团队研发的一条公有链,旨在打造一款让全球普罗大众都能拥有和使用的加密数字货币π。它以全球贸易为开端,真正实现个人财富的独立可控、自由支配,是人类金融史上的...

  • 5

    referer,正确写法referrer,指的是网站的一种安全策略,在请求头CSP(Content-Security-Policy),标签或者是指定的html标签里都可以设置它,它指的是上一个请求的来源记录,比如你从a1通过链连,跳到a2,那在a2的请求头里,就会有a1的网址或者域名,这个和referrer策...

  • 4

    问题的产生 对于我们的容器化部署项目keycloak来说,当它从云端负载均衡LB直接通过 NodePort转发到keycloak时,没有任务问题,一切正常;缺点就是,运维人员要维护一大批端口,哪个端口对应哪个服务,非常容易出乱子。

  • 3

    首先我们应该知道,写到数据库里的时间,主要和你的mysql时区system_time_zone有关,而把mysql里的数据取出来,以json形式响应到浏览器上,这个时间会经过反序列化的过程,这时时间和注解@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK