首页 > 解决方案 > cookie 设置为安全,但您的重定向 url 在 keycloak-gatekeeper 中是非 tls 错误

问题描述

[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

标签: docker-composekeycloak

解决方案


错误中包含所有内容: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.) 禁用安全 cookiesecure-cookie: false

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


推荐阅读