Skip to content

Commit

Permalink
add tenant-cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
igurucelain committed Jul 3, 2023
1 parent b760a2c commit 19b2d36
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rootfs/etc/nginx/lua/stratio_auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,19 @@ function _M.create_cookie(userinfo_url, oauth2_cookie_name, stratio_cookie_name,
end

-- add stratio-tenant cookie
local jwt = require "resty.jwt"
local decoded_jwt = jwt:load_jwt(stratio_jwt)
local tenant = decoded_token.payload.tenant
local tenant = decoded_jwt.payload.tenant
local tenant_cookie_name = os.getenv("STRATIO_TENANT_COOKIE_NAME")
if tenant_cookie_name == nil then
tenant_cookie_name = 'stratio-tenant'
end

ngx.log(ngx.DEBUG, 'Adding cookies to request')
-- TODO REMOVE BEFORE MERGE
ngx.log(ngx.INFO, 'COOKIE NAME: ',tenant_cookie_name)
ngx.log(ngx.INFO, 'DEFAULT TENANT: ',tenant)
-- UNTIL HERE
ngx.req.set_header("Cookie", stratio_cookie_name .. "=" .. stratio_jwt .. ";" .. ngx.var.http_cookie);
ngx.req.set_header("Cookie", tenant_cookie_name .. "=" .. tenant .. ";" .. ngx.var.http_cookie);

Expand Down

0 comments on commit 19b2d36

Please sign in to comment.