需要身份验证 - Windows Server上的Python CGI

问题描述:

我的英语很差。我很抱歉。需要身份验证 - Windows Server上的Python CGI

我用plesk面板购买了Wİndows服务器。 我加载到FTP python脚本。因为该网站是用python编写的。

当我进入该网站时,我看到“需要验证”。但我想看看这个窗口。我希望每个人都可以进入该网站并运行到cgi脚本。

我该如何做到这一点?

+0

很抱歉,但我不明白。 –

upd.you改写你的问题?

cgi打印http响应标准输出。 首先,您需要获取标题......如果标题“授权”存在,您可以从中解码登录名和密码。 如果没有这样的头文件或passord无效,您必须: 发送401响应 发送包含'Basic realm = \'Message''的'WWW-Authenticate'标头用于基本授权。也可能Digest,Ntlm等

如果浏览器得到401响应,它要求用户输入密码(即使ajax),用服务器请求的方法编码登录名和密码,再用'授权'标头发送请求。

不是CGI代码示例,装饰商的HttpServer,BaseHTTPRequestHandler

def login_required(f): 
def authenticate(self,*args,**kwargs): 

    if conf.get('noauth'): 
     return f(self,*args,**kwargs) 

    if self.headers.getheader('Authorization') : 
     cred = base64.b64decode(self.headers.getheader('Authorization').split(' ')[1]) 


     users = conf.get('users', []) 
     if cred in users: 
      self.creds = cred 
      return f(self,*args,**kwargs) 
#else 
    self.send_response(401) 
    self.send_header('WWW-Authenticate', 'Basic realm=\"Meter\"') 
    self.send_header('Content-type', 'text/html') 
    self.end_headers() 
    self.wfile.write('Not authenticated.') 
    return False 
return authenticate 
+0

谢谢。我会尝试 – user1898723