Commit 156b8cbc authored by Zach Perkins's avatar Zach Perkins

it kind of works but it also doesn't and that's ok

parent 41a23620
......@@ -2,14 +2,17 @@ from flask import Flask, redirect, jsonify, abort, request, url_for, make_respon
from webargs.flaskparser import use_args
from webargs import fields
from where.model import Session, Point, Category, Field
from where.model.field_types import FieldType
from where.model import Session, Point, Category, Field, FieldType
from where.validation import PointSchema, CategorySchema, FieldSchema
from where import auth
from where.auth import authenticated
from flask_jwt_extended import create_access_token
app = Flask(__name__)
app.config['JWT_SECRET_KEY'] = 'potato' # Note: Do not use potato in production
auth.init(app)
......@@ -30,6 +33,11 @@ def destroy_local_db_session(resp):
return resp
@app.route('/auth')
def authenticate():
return(jsonify(auth_url=auth.get_auth_url()))
@app.route('/validate-auth')
@use_args({'ticket': fields.Str(required=True)})
def validate_auth(args):
......@@ -37,6 +45,7 @@ def validate_auth(args):
@app.route('/')
@authenticated()
def index():
print(PointSchema().Meta.model)
return """
......
from flask import request, g, make_response
from flask import request, g, make_response, url_for
from urllib import parse
import requests
import xml.etree.ElementTree as et
......@@ -36,12 +36,12 @@ def authenticated(level=AccessLevel.USER, pass_user=False):
return func(*args, **kwargs)
return wrapper
return decorator
def format_service_name():
return parse.quote(request.base_url)
return parse.quote('https://' + request.host + url_for('validate_auth'))
def get_auth_url():
......
from enum import Enum, unique
from enum import Enum, IntEnum, unique
class FieldType(Enum):
......@@ -38,6 +38,6 @@ class FieldType(Enum):
@unique
class AccessLevel(Enum):
USER = 0
ADMIN = 1
class AccessLevel(IntEnum):
USER = 1
ADMIN = 2
from where.model import Session, Point, Category, Field
from where.model.field_types import FieldType
from where.model import Session, Point, Category, Field, FieldType, User, AccessLevel
from flask import g
......@@ -77,4 +76,8 @@ def create_test_data():
}
g.db_session.add(fn)
user = User(access_level=AccessLevel.USER, net_id='zperkin')
g.db_session.add(user)
g.db_session.commit()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment