【发布时间】:2019-09-26 21:28:09
【问题描述】:
我正在构建一个 SSO 登录,旨在通过电子邮件发送的链接使用。
每个链接都应该自动连接用户 (SSO),并且可以多次点击(它们有一个 TTL,这取决于电子邮件)
它工作正常,但我担心最终用户在社交网络上分享他的 url(基本上是复制/粘贴包含 SSO 令牌的 url),从而允许任何点击链接的人自动登录。
我的第一次尝试是尝试从我的 SSOM 中间件中删除 GET SSO_TOKEN 参数,如下所示:
if remove_token_middleware:
request.GET._mutable = True # GET is not mutable by default, we force it
# Remove the token from the url to avoid displaying it to the client (avoids sharing sso token when copy/pasting url)
del request.GET[SSO_TOKEN_PARAM]
request.GET._mutable = False # Restore default mutability
return login(request, user) if service.get("auto_auth") else None
基本上,我的想法是,由于 SSO_TOKEN 位于 request.get 对象中,因此将其从中删除最终会更改用户被重定向的 url
在我的控制器中,这里是用户如何被“重定向”(使用render)
return render(request, 'campagne_emprunt/liste_offres_prets.html', locals())
当使用render 时,没有重定向,SSO 令牌在 URL 中仍然可见(在浏览器地址栏中)。
有没有办法告诉 Django 即时更改目标 url?
【问题讨论】:
标签: python django single-sign-on