我尝试使用记录的方式来限制访问标记为静态的URL,方法是登录:app.yaml文件中的必需规则。我的目的是通过xmlhttprequests访问由go编程语言处理的脚本URL,但是在加载文件dist / index.html之前验证用户的第一步失败。
令我惊讶的是,我没有提示用户登录,而是从静态文件夹接收dist / index.html文件及其要求的所有其他文件,就像没有限制规则一样。
这是我的app.yaml文件:
application: helloworld
version: 1
runtime: go
api_version: go1
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
secure: always
login: required - this is what fails as far as I'm concerned
- url: /(.*\.(txt|html|json|png|js|log|md|css|ico))
static_files: dist/\1
upload: dist/(.*\.(txt|html|json|png|js|log|md|css|ico))
secure: always
login: required
- url: /.*
script: _go_app
secure: always
login: required
我上传到appengine的文件夹如下所示:
app.yaml
index.yaml
xhr_responses.go - this is the intended future non static AJAX part
dist/
index.html
loads of other stuff that is static
答案 0 :(得分:1)
.yaml
配置文件中的'login:'处理程序选项依赖于Google的身份验证,该身份验证可以使用Cookie保留,并在浏览器重启后继续存在。
要正确测试身份验证,您需要使用新的隐身浏览器会话或访问其中一个Google网站,并确保在测试之前未登录(如果需要,请明确退出所有Google帐户)。
答案 1 :(得分:0)
显然,当我在实时谷歌应用引擎上尝试内容时我已经登录了,我忘记了它是否知道不会将访问重定向到新的登录提示。