Skip to content

Commit

Permalink
Make session_auth_name actually nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffy-critter committed Aug 1, 2020
1 parent 9dcb7a0 commit 6df6769
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion authl/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def __init__(self,
tester_path: str = None,
login_render_func: typing.Callable = None,
notify_render_func: typing.Callable = None,
session_auth_name: str = 'me',
session_auth_name: typing.Optional[str] = 'me',
force_https: bool = False,
stylesheet: typing.Union[str, typing.Callable] = None,
on_verified: typing.Callable = None,
Expand Down
21 changes: 21 additions & 0 deletions tests/test_flask_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,24 @@ def initiate_auth(self, id_url, callback_uri, redir):
assert response.headers['Location'] == 'http://localhost/'
response = client.get('/')
assert response.data == b'hello https://login.example/larry/auth'


def test_session_override():
app = flask.Flask(__name__)
app.secret_key = 'poiu'

stash = {}

def on_verified(disp):
stash['v'] = disp

authl.flask.setup(app,
{'TEST_ENABLED': True},
session_auth_name=None,
on_verified=on_verified)

with app.test_client() as client:
client.get('/login/?me=test:poiu')
assert 'me' not in flask.session
assert isinstance(stash['v'], disposition.Verified)
assert stash['v'].identity == 'test:poiu'

0 comments on commit 6df6769

Please sign in to comment.