Browse Source

Disable sessions

merge-requests/1/head
Drew Short 7 years ago
parent
commit
897b7154e3
  1. 3
      server/atheneum/__init__.py
  2. 16
      server/atheneum/utility/session_utility.py
  3. 10
      server/manage.py

3
server/atheneum/__init__.py

@ -6,7 +6,7 @@ from flask import Flask
from flask_migrate import Migrate
from atheneum.db import db
from atheneum.utility import json_utility
from atheneum.utility import json_utility, session_utility
dictConfig({
'version': 1,
@ -61,6 +61,7 @@ def create_app(test_config: dict = None) -> Flask:
pass
app.json_encoder = json_utility.CustomJSONEncoder
app.session_interface = session_utility.DisableSessionInterface()
app.logger.debug('Initializing Application')
db.init_app(app)

16
server/atheneum/utility/session_utility.py

@ -0,0 +1,16 @@
"""Session specific utilities."""
from typing import Any
from flask.sessions import SecureCookieSessionInterface
class DisableSessionInterface(SecureCookieSessionInterface):
"""Make sure no session data is transmitted or stored."""
def should_set_cookie(self, app: Any, session: Any) -> bool:
"""Disable default cookie generation."""
return False
def save_session(self, app: Any, session: Any, response: Any) -> Any:
"""Prevent creating session from requests."""
return None

10
server/manage.py

@ -1,8 +1,9 @@
import base64
import logging
import random
import string
from typing import Optional
from os import path
from typing import Optional
import click
from click import Context
@ -111,7 +112,14 @@ def list_users():
[click.echo(user.name) for user in all_users]
@click.command(name='base64')
@click.argument('text')
def convert_to_base64(text: str):
print(base64.b64encode(text.encode('utf8')).decode('utf8'))
main.add_command(user_command_group)
main.add_command(convert_to_base64)
user_command_group.add_command(register_user)
user_command_group.add_command(register_admin_user)
user_command_group.add_command(delete_user)

Loading…
Cancel
Save