Keycloak 和 Google OAuth 2.0 重定向 URI 不匹配

问题描述 投票:0回答:1

我有网站https://fm.xxxxx.com 域名已注册

我使用一些负载均衡器作为 nginx,并为 keycloak 进行重定向配置

server {
        listen 80;
        listen [::]:80;
        server_name fm.xxxxx.com;
        return 301 https://fm.xxxxx.com;
}

server {
  listen 443 ssl;
  server_name fm.xxxxx.com;

  ssl_certificate /etc/nginx/certificate/xxxxx.crt;
  ssl_certificate_key /etc/nginx/certificate/xxxxx.key;

 location /realms/fm-users/ {
    proxy_read_timeout 90;
    proxy_pass http://fm-keycloak:8080;
    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-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Scheme $scheme;

    client_max_body_size 30m;
 }

 location /resources/ {
    proxy_read_timeout 90;
    proxy_pass http://fm-keycloak:8080;
    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-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Scheme $scheme;

    client_max_body_size 30m;
 }...

当我尝试在 keycloak 中设置 google 身份提供商时 我创建了 google 提供程序,并在 google 配置中使用重定向 URI

enter image description here

但谷歌不喜欢 URI

enter image description here

我无法更改 keycloak 身份提供商中的重定向 uri 并且对 google 无效

我尝试使用域名代替IP

enter image description here

但是当我尝试使用谷歌登录时它发送错误

错误400:当然是redirect_uri_mismatch

enter image description here

enter image description here

我的网站使用 https,keycloak 不使用

如何更改 keycloak 中身份提供者中的重定向 URI?

或者我能做什么?

我尝试将redirectUri参数添加到keycloak import.json文件中 并将redirectUri参数添加到keycloak数据库中的identity_provider_config表中 这没有帮助

当我使用 127.0.0.1 并在本地运行其所有作品时 但我需要它来生产并在 keycloak 中使用域或在 google 中使用 ip

也许我需要使用 nginx.conf 创建一些重定向?

oauth-2.0 google-oauth keycloak redirect-uri-mismatch identity-provider
1个回答
0
投票

https://www.youtube.com/watch?si=977UR0srgX8awbD4&v=QHz1Rs6lZHQ&feature=youtu.be

我只需要将重定向 uri 从错误复制到 url google 凭证...

端口是多余的

© www.soinside.com 2019 - 2024. All rights reserved.