# passage-python
This Python SDK allows for verification of server-side authentication for applications using [Passage](https://passage.id)
Install this package using [pip](https://pypi.org/project/passage-identity/).
```
pip install passage-identity
```
## Authenticating a Request
To authenticate an HTTP request in a Flask application, you can use the Passage library in a middleware function.
You need to provide Passage with your app handle in order to verify the JWTs.
```python
from passageidentity import Passage
import os
PASSAGE_APPHANDLE = os.environ.get("PASSAGE_APPHANDLE")
def exampleFlaskMiddleware(request):
psg = Passage(PASSAGE_APPHANDLE)
user = psg.authenticateRequest(request)
```
## Retrieve User Info
To retrieve information about a user, you should use the `getPassageUser` method. You will need to use a Passage API key, which can be created in the Passage Console under your Application Settings. This API key grants your web server access to the Passage management APIs to get and update information about users.
This API key must be protected and stored in an appropriate secure storage location. It should never be hard-coded in the repository.
```python
from passageidentity import Passage
import os
PASSAGE_APPHANDLE = os.environ.get("PASSAGE_APPHANDLE")
PASSAGE_API_KEY = os.environ.get("PASSAGE_API_KEY")
psg = Passage(PASSAGE_APPHANDLE, PASSAGE_API_KEY)
def exampleFlaskMiddleware(request):
g.user = psg.authenticateRequest(request)
@auth.route('/home')
def authenticatedEndpoint():
user = psg.getPassageUser(g.user)
print(user.email)
```
The information available in the Passage User object is as
| Field | Type |
|--------|---------|
| handle | string |
| email | string |
| active | boolean |
| email_verified | boolean |
| start_date | Datetime |
| last_login_date | Datetime |
| password | boolean |
| webauthn | boolean |
| webauthn_devices | array |
|recent_events| array of PassageEvents |
没有合适的资源?快使用搜索试试~ 我知道了~
资源分类:Python库 所属语言:Python 资源全名:passage-identity-0.0.7.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论



















收起资源包目录

















共 13 条
- 1
- 2
- 3
资源评论

挣扎的蓝藻
- 粉丝: 8w+
- 资源: 15万+

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制
