Keycloak KeyClope AuthenticationFlowContext始终返回http协议

Keycloak KeyClope AuthenticationFlowContext始终返回http协议,keycloak,Keycloak,我正在实现验证器类并使用AuthenticationFlowContext。当我通过HTTPS引用服务器时,context.getUriInfo()中的getAbsolutePath()仍然保留http://{hostname}/auth/ public void authenticate(AuthenticationFlowContext context) { String url = context.getUriInfo().getAbsolutePath()+"?client_i

我正在实现验证器类并使用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());

}

您必须配置KeyClope和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