提交 97aaead9239b4c17d81b3eacd5073d465f8932ae

作者 qianyingz
1 个父辈 62c596fe

解决无法获取accesstoken的问题

... ... @@ -8,6 +8,7 @@ from .oauth2 import authorization, require_oauth, generate_user_info
8 8 from authlib.oauth2 import OAuth2Error
9 9 from authlib.integrations.flask_oauth2 import current_token
10 10
  11 +
11 12 def current_user():
12 13 if 'id' in session:
13 14 uid = session['id']
... ... @@ -34,7 +35,7 @@ class DataManager(BlueprintApi):
34 35
35 36 @staticmethod
36 37 @bp.route('/', methods=('GET', 'POST'))
37   - def test():
  38 + def Login():
38 39 if request.method == 'POST':
39 40 username = request.form['username']
40 41 password = request.form['password']
... ... @@ -52,8 +53,6 @@ class DataManager(BlueprintApi):
52 53 else:
53 54 clients = []
54 55 return render_template('auth/login.html', user=user, clients=clients)
55   -
56   -
57 56
58 57 @staticmethod
59 58 @bp.route('/create_client', methods=('GET', 'POST'))
... ... @@ -85,7 +84,7 @@ class DataManager(BlueprintApi):
85 84 db.session.add(client)
86 85 db.session.commit()
87 86 return redirect('/auth')
88   -
  87 +
89 88 @staticmethod
90 89 @bp.route('/authorize', methods=('GET', 'POST'))
91 90 def authorize():
... ... @@ -104,13 +103,12 @@ class DataManager(BlueprintApi):
104 103 else:
105 104 grant_user = None
106 105 return authorization.create_authorization_response(grant_user=grant_user)
107   -
108   -
  106 +
109 107 @staticmethod
110 108 @bp.route('/token', methods=['POST'])
111 109 def issue_token():
112 110 return authorization.create_token_response()
113   -
  111 +
114 112 @staticmethod
115 113 @bp.route('/userinfo')
116 114 @require_oauth('profile')
... ...
... ... @@ -26,6 +26,7 @@ DUMMY_JWT_CONFIG = {
26 26 'exp': 7200,
27 27 }
28 28
  29 +
29 30 def exists_nonce(nonce, req):
30 31 exists = OAuth2AuthorizationCode.query.filter_by(
31 32 client_id=req.client_id, nonce=nonce
... ... @@ -34,7 +35,7 @@ def exists_nonce(nonce, req):
34 35
35 36
36 37 def generate_user_info(user, scope):
37   - return UserInfo(sub=str(user.id), name=user.username)
  38 + return UserInfo(sub=str(user.id), name=user.username, role=user.role, company=user.company)
38 39
39 40
40 41 def create_authorization_code(client, grant_user, request):
... ...
... ... @@ -3,7 +3,7 @@
3 3 # 程序部署ip:host
4 4 deploy_ip_host = "172.26.99.160:8840"
5 5 # 系统数据库
6   -SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@172.26.40.254:5433/dmap_dms_test"
  6 +SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@localhost:5433/dmap_dms_test"
7 7
8 8
9 9 # 部署模式cluster,standalone
... ...
注册登录 后发表评论