小编Vim*_*nyu的帖子

向 SSO 保护资源发出 GET 请求

我需要通过 GET 调用访问数据,但资源受单点登录保护。我有 URI 端点和单点登录凭据。我开始使用 XMLHttpRequest() 发出 ajax 请求,但得到了这个:

被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin”标头。

由于我无权访问服务器,因此无法将“Access-Control-Allow-Origin”设置为 true,因此我决定转而使用带有 Flask 后端的 Python 请求库进行调用。我尝试将用户凭据与 GET 请求一起传递,如下所示:

headers = {'accept': 'application/json;odata=verbose'}
r = requests.get(url, auth=HTTPBasicAuth(userid, password), headers=headers)
print r.status_code #prints 403
print r.content #prints 403 forbidden
Run Code Online (Sandbox Code Playgroud)

有没有办法访问这样的资源?请注意,SSO 是使用 SAML 2.0 配置的

更新: 跟踪 giaco 建议的链接后,我现在可以以编程方式登录到 SSO。至少,我认为是这样..(s.post(..) 返回的 HTML 实际上仍然有 403 禁止代码——但是当我在浏览器中点击 url 时,它重定向到登录页面)但是,当我发送 GET请求,我再次收到 403 FORBIDDEN 消息。以下是更新后的代码:

payload = {
    'UserName': username,
    'Password': password
    }
    print "configured payload" #successfully printed on console

    with requests.Session() as s:
        p …
Run Code Online (Sandbox Code Playgroud)

python ajax https xmlhttprequest single-sign-on

8
推荐指数
0
解决办法
1万
查看次数

在文件ld-linux-x86-64.so.2中未定义版本GLIBC_PRIVATE

是否有人可以在gcc版本问题上给初学者一些帮助?

我在遇到了这个问题"version GLIBCXX_3.4.20' not found"。在我链接之后:如何在CentOS 7.2上用yum安装gcc 5.3? 我遇到了以下额外问题:

scl enable devtoolset-7 bash
git: relocation error: libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference 
Run Code Online (Sandbox Code Playgroud)

gcc libc

7
推荐指数
1
解决办法
1万
查看次数

Python 内置函数的时间复杂度?

有没有什么好的参考资源可以了解Python内置函数(如 , )的时间复杂dict.fromkeys().lower()?我找到了像UCI 资源这样的链接,其中列出了基本列表和集合操作的时间复杂度,但当然,并非所有内置操作都列出了时间复杂度。我还找到了 Python Reference - The Right Way,但大多数参考文献都有#TODO 以表示时间复杂度。

我也尝试阅读Python内置函数的源代码来弄清楚这些功能是如何dict.fromkeys()实现的,但感觉很失落。

big-o python-3.x

5
推荐指数
1
解决办法
4310
查看次数

Unable to change nginx.conf file

I have a vagrant-box running CentOS6.7 on which I am running docker containers. I intend to run flask applications served by nginx inside the container. I had to make certain changes inside the nginx.conf file to serve my application (app1) by nginx. This may seem a little strange, but I am not able to change nginx.conf file inside /etc/nginx/conf.d/nginx.conf

Here is what I did:

Method1: Change in Dockerfile

My Dockerfile looks like this:

FROM tiangolo/uwsgi-nginx-flask:flask
COPY ./app /app
COPY ./changes/nginx.conf …
Run Code Online (Sandbox Code Playgroud)

nginx flask vagrant docker

4
推荐指数
1
解决办法
8863
查看次数