要通过ESIA准备授权,我们需要
nginx本身及其插件
cryptod -session ,
headers-more ,
auth_request ,
uuid4 ,
set-misc ,
echo ,
json ,
sign和
jwt 。 (我提供了到fork的链接,因为我做了一些尚未塞入原始存储库的更改。您还可以使用
现成的图像 。)
首先,让我们进行设置
encrypted_session_key "abcdefghijklmnopqrstuvwxyz123456";
接下来,以防万一,禁用授权标头
more_clear_input_headers Authorization;
现在我们通过授权保护一切
auth_request /auth; location =/auth { internal; set_decode_base64 $auth_decode $cookie_auth;
对于授权用户,我们显示其文件夹中的内容
location / { alias html/$remote_user/; }
在没有授权的情况下,我们重定向到ESIA
error_page 401 = @error401; location @error401 { set $client_id ;
在ESIA中成功授权用户后,他将被重定向到寄信人地址
location =/login { auth_request off;