cookie 设置为安全但您的重定向 url 是 keycloak-gatekeeper 中的非 tls 错误

the cookie is set to secure but your redirection url is non-tls error in keycloak-gatekeeper

[error] the cookie is set to secure but your redirection url is non-tls

在我的 keycloak-gatekeeper 容器中遇到这个问题

在我的 .conf 文件下面

discovery-url: http://localhost:8180/auth/realms/employee-ms/keys
skip-openid-provider-tls-verify: true
client-id: employee-admin

client-secret:

listen: :3000

enable-refresh-tokens: true
tls-cert:
tls-private-key:
redirection-url: http://localhost:8084/*
encryption-key: vGcLt8ZUdPX5fXhtLZaPHZkGWHZrT6aa
upstream-url: http://employee:80/
scopes:

resources:
- uri: /*
  methods:
  - GET

- uri: /admin/*
  methods:
  - GET
  roles:
  - openvpn:vpn-user
  - openvpn:prod-vpn

- uri: /admin/*
  methods:
  - GET
  roles:
  - openvpn:vpn-user
  - openvpn:commons-prod-vpn

错误中包含所有内容:the cookie is set to secure but your redirection url is non-tls(http 协议是非 tls 协议,因此您需要 https 协议)。

有默认值 secure-cookie: true,它与您的配置不兼容 redirection-url: http://localhost:8084/*

您有 2 个选择:

1.) 为您的应用配置 TLS,然后您可以 redirection-url: https://localhost:8084/*

2.) 禁用安全 cookie secure-cookie: false

选项 1 更好更安全,因为 OIDC 协议需要 TLS(您应该也为 Keycloak 使用 TLS)。