httpauth是一個WSGI中間件固定使用HTTP摘要式身份驗證的一些/所有路由。
安裝
PIP安裝httpauth
使用憑據字典
secured_wsgi_app = httpauth.DictHttpAuthMiddleware(
  {'user1的“:”密碼1“,”用戶2“:”密碼2“},
  wsgi_app = unsecured_wsgi_app,
 #境界='安全內容',#可選
)
使用帶有.htdigest文件
secured_wsgi_app = httpauth.DigestFileHttpAuthMiddleware(
 開('/路徑/要/你/ .htdigest'),
  wsgi_app = unsecured_wsgi_app,
)
可以使用htdigest阿帕奇工具創建.htdigest文件。
確保只有一些網址
如果有,路由參數(正則表達式的列表)指定的URL進行擔保。 (默認情況下,所有的URL都是安全的。)
secured_wsgi_app = httpauth.DictHttpAuthMiddleware(
  {'用戶':'密碼'},
  wsgi_app = unsecured_wsgi_app,
 路線= ['^ /管理/','^ /其它/秘密/頁/ $'],
)
要求:
- 在Python中
評論沒有發現