重定向上的瓶子设置授权标头

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

我有一个Python / Bottle服务器应用程序,一个Seaweed媒体服务器和一个NGINX Web服务器。在允许填充程序下载文件之前,我需要检查客户的许可。因此:

  1. 用户请求下载文件。
  2. 后端检查用户权限。如果被授予,则将其重定向到文件位置。

但是问题是必须设置由JWT保护的海藻和Authorization标头。

我可以设置授权标头,然后重定向用户吗?

python http-headers bottle http-redirect
1个回答
0
投票

是的,您可以在重定向上设置标题。这是在Bottle中完成的一种方法:

@route(...)
def handler():
    # after you've authorized the user, set your auth header:
    response.set_header('Your-auth-header', auth_token)

    # perform the redirect
    response.status = 302
    response.body = ''
    response.set_header('Location', file_location)
    raise response

((超出我的头脑;未经测试的代码。)

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