我正在实现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());
}
答案 0 :(得分:0)
您必须配置keycloak server和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。