authentication by reverse proxy
This commit is contained in:
parent
c6db7909b8
commit
509f97a9f5
10 changed files with 120 additions and 13 deletions
5
realms/modules/auth/proxy/__init__.py
Normal file
5
realms/modules/auth/proxy/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from realms.modules.auth.models import Auth
|
||||
|
||||
Auth.register('proxy')
|
42
realms/modules/auth/proxy/models.py
Normal file
42
realms/modules/auth/proxy/models.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from flask_login import login_user
|
||||
|
||||
from realms.modules.auth.models import BaseUser
|
||||
|
||||
|
||||
users = {}
|
||||
|
||||
|
||||
class User(BaseUser):
|
||||
type = 'proxy'
|
||||
|
||||
def __init__(self, username, email='null@localhost.local', password="dummypassword"):
|
||||
self.id = username
|
||||
self.username = username
|
||||
self.email = email
|
||||
self.password = password
|
||||
|
||||
@property
|
||||
def auth_token_id(self):
|
||||
return self.password
|
||||
|
||||
@staticmethod
|
||||
def load_user(*args, **kwargs):
|
||||
return User.get_by_id(args[0])
|
||||
|
||||
@staticmethod
|
||||
def get_by_id(user_id):
|
||||
return users.get(user_id)
|
||||
|
||||
@staticmethod
|
||||
def login_form():
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def do_login(user_id):
|
||||
user = User(user_id)
|
||||
users[user_id] = user
|
||||
login_user(user, remember=True)
|
||||
return True
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue