【问题标题】:Keycloak AuthenticationFlowContext return always http protocolKeycloak AuthenticationFlowContext 总是返回 http 协议
【发布时间】:2016-04-22 19:12:10
【问题描述】:

我正在实现 Authenticator 类并使用 AuthenticationFlowContext。当我通过 HTTPS 引用服务器时,在 context.getUriInfo().getAbsolutePath() 中仍然留下 http://{hostname}/auth/... 。

public void authenticate(AuthenticationFlowContext context) {

    String url = context.getUriInfo().getAbsolutePath()+"?client_id="+context.getClientSession().getClient().getClientId()
            +"&redirect_uri="+context.getClientSession().getNote("redirect_uri")
            +"&state="+context.getClientSession().getNote("state")
            +"&response_type="+context.getClientSession().getNote("response_type");

    try {
        url = URLEncoder.encode(url, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    context.forceChallenge(Response.seeOther(URI.create(idpUrl+"idp/l?lvl=2&url="+url)).build());

}

【问题讨论】:

    标签: keycloak


    【解决方案1】:

    必须配置keycloakserver和nginx:

    location /  {
           proxy_set_header Host                $host;
           proxy_set_header X-Real-IP           $remote_addr;
           proxy_set_header X-Forwarded-For     $proxy_add_x_forwarded_for;
           proxy_set_header X-Forwarded-Proto   $scheme;
           proxy_set_header X-Forwarded-Port    443;
    
           proxy_pass  http://localhost:8080;
        }
    

    Https 已启用。

    【讨论】:

      猜你喜欢
      • 2018-04-03
      • 1970-01-01
      • 2013-02-01
      • 2019-01-09
      • 2021-11-13
      • 2021-01-29
      • 1970-01-01
      • 1970-01-01
      • 2012-07-25
      相关资源
      最近更新 更多