diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-02 17:58:15 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-02 17:58:15 -0800 |
commit | 10ddca2c2fd6b14bbd94fe57aed66a6de03e1777 (patch) | |
tree | 5dc7e5794210e4a6b9769dc899d288005325b182 /python/fatcat_web/auth.py | |
parent | 25e6a55305b24218be76c9edfe3df0f88ce13234 (diff) | |
download | fatcat-10ddca2c2fd6b14bbd94fe57aed66a6de03e1777.tar.gz fatcat-10ddca2c2fd6b14bbd94fe57aed66a6de03e1777.zip |
start on webface oauth2/oidc web auth
Diffstat (limited to 'python/fatcat_web/auth.py')
-rw-r--r-- | python/fatcat_web/auth.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/python/fatcat_web/auth.py b/python/fatcat_web/auth.py new file mode 100644 index 00000000..f6672e87 --- /dev/null +++ b/python/fatcat_web/auth.py @@ -0,0 +1,27 @@ + +from flask import Flask, render_template, send_from_directory, request, \ + url_for, abort, g, redirect, jsonify, session +from fatcat_web import login_manager + + +# This will need to login/signup via fatcatd API, then set token in session +def handle_oauth(remote, token, user_info): + print(remote) + if token: + print(remote.name, token) + if user_info: + # TODO: fetch api login/signup using user_info + print(user_info) + # TODO: write token and username to session + # TODO: call login_user(load_user(editor_id)) + return redirect("/") + raise some_error + + +@login_manager.user_loader +def load_user(editor_id): + # NOTE: this should look for extra info in session, and update the user + # object with that. If session isn't loaded/valid, should return None + user = UserMixin() + user.id = editor_id + return user |