Flask - 活动目录认证 [英] Flask - Active Directory Authentication

查看:135
本文介绍了Flask - 活动目录认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个小的Flask应用程序,我希望用户能够使用他们的Windows NT ID进行身份验证。我不是IT团队的一员,所以我对这个领域的了解有限,而且我的IT团队对Python没有经验。

配置有多简单这个?我试图做一些谷歌搜索,我看到了LDAP模块和Flask-Security。我希望有一个快速指南或指向一个特定的方向。


  • 有一个现有的活动目录和我们的很多内部网站使用NT身份验证

  • 我制作了一个Flask应用程序,我将移植到我们的内部网络
  • 我希望用户能够登录到我需要知道我需要什么信息(一个LDAP服务器和端口?),或者我需要用IT来做这个配置,而不会破坏任何安全协议



感谢!

解决方案

使用Flask很容易,因为它是基于轻量级和基于插件的Python Web框架。
$ b


LDAP配置需要的东西





  • LDAP主机

  • LDAP域

  • LDAP配置文件密钥




您需要安装Flask-LDAP p lugin




  pip install Flask-LDAP 

以下是一个基本的例子:

  from flask import Flask 
from flask.ext.ldap import LDAP,login_required

app = Flask(__ name__)
app.debug = True

app.config ['LDAP_HOST'] ='ldap.example.com'
app.config ['LDAP_DOMAIN'] ='example.com'
app.config ['LDAP_SEARCH_BASE'] ='OU = Domain Users,DC = example,DC = com'

ldap = LDAP(app)
app.secret_key =welfhwdlhwdlfhwelfhwlehfwlehfelwehflwefwlehflwefhlwefhlewjfhwelfjhweflhweflhwel
app.add_url_rule('/ login', 'login',ldap.login,methods = ['GET','POST'])

@ app.route('/')
@ ldap.login_required
def index():
pass
$ b $ @ app.route('/ login',methods = ['GET','POST'])$ b $#def login()
#传递

if __name__ =='__main__':
app.run(de bug = True,host =0.0.0.0)

更多细节可以在这里


I made a small Flask application and I would like users to be able to authenticate with their Windows NT IDs. I am not a part of the IT team, so I have limited insight into this area and my IT team is not experienced with Python.

How easy would it be to configure this? I tried to do some Googling and I saw LDAP modules and Flask-Security. I am hoping for a quick guide or to be pointed into a specific direction.

  • There is an existing Active Directory and a lot of our internal websites use NT authentication
  • I made a Flask app that I will be porting to our internal network
  • I want users to be able to login to the site with their NT ID
  • I need to know what information I need (an LDAP server and port?) or what I need to do with IT to get this configured properly without breaking any security protocols

Thanks!

解决方案

It is quite easy to work with Flask as it is lightweight and plugin based Python web framework

Things you will need for LDAP Configuration

  • LDAP Host
  • LDAP Domain
  • LDAP Profile Key

You need to install Flask-LDAP plugin

pip install Flask-LDAP

and here is a basic example to get you started:

from flask import Flask
from flask.ext.ldap import LDAP, login_required

app = Flask(__name__)
app.debug = True

app.config['LDAP_HOST'] = 'ldap.example.com'
app.config['LDAP_DOMAIN'] = 'example.com'
app.config['LDAP_SEARCH_BASE'] = 'OU=Domain Users,DC=example,DC=com'

ldap = LDAP(app)
app.secret_key = "welfhwdlhwdlfhwelfhwlehfwlehfelwehflwefwlehflwefhlwefhlewjfhwelfjhweflhweflhwel"
app.add_url_rule('/login', 'login', ldap.login, methods=['GET', 'POST'])

@app.route('/')
@ldap.login_required
def index():
        pass

# @app.route('/login', methods=['GET', 'POST'])
# def login():
#     pass

if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0")

More details can be found here

这篇关于Flask - 活动目录认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆