Example #1
0
def slack_oauth_callback(event, context):
    req_session = RequestSession(event)
    req_error = req_session.validate_authorized_request(
        False, [], ['code', 'state'])
    if req_error:
        return req_error

    url = oauth.oauth_callback(req_session.get_req_param('code'),
                               req_session.get_req_param('state'))
    if not url:
        req_session.generate_error_response(401, "Not authenticated")
    else:
        return req_session.generate_redirect_response(url)
def post_datasource(event, context):
    req_session = RequestSession(event)
    req_error = req_session.validate_authorized_request()
    if req_error:
        return req_error

    try:
        datasource = domain_controller.create_datasource(req_session.get_auth_token(), req_session.get_body())
    except Exception as ex:
        return req_session.generate_error_response(400, ex.message)
    return req_session.generate_sqlalchemy_response(200, datasource)
Example #3
0
def current_user(event, context):
    req_session = RequestSession(event)
    req_error = req_session.validate_authorized_request()
    if req_error:
        return req_error

    user_session = auth_controller.get_user_session(
        req_session.get_auth_token())

    if not user_session:
        return req_session.generate_error_response(401,
                                                   "User session not found")
    else:
        return req_session.generate_sqlalchemy_response(200, user_session)