# Path: logviewer/auth/base.py
# class AuthBackend(object):
#     def login(self, error=None):
#         raise NotImplementedError()
# 
#     def authenticate(self):
#         raise NotImplementedError()
# 
# Path: logviewer/exc.py
# class AuthenticationError(RuntimeError):
#     pass


import hashlib
import hmac
import json
import requests
from flask import request, current_app, render_template
from .base import AuthBackend
from ..exc import AuthenticationError
# -*- coding: utf-8 -*-



class LangDevAuth(AuthBackend):
    def __init__(self, app_key=None, secret_key=None):
        self._app_key = app_key
        self._secret_key = secret_key

    def login(self, error=None):
        return render_template('auth/basic.html', error=error,
                               next=request.args.get('next'))

    def authenticate(self):
        auth = self.langdev_sso_call(request.form['username'],
                                     request.form['password'])
        if auth:
            return {
                'username': request.form['username'],
            }
        else:

# Path: logviewer/auth/base.py
# class AuthBackend(object):
#     def login(self, error=None):
#         raise NotImplementedError()
# 
#     def authenticate(self):
#         raise NotImplementedError()
# 
# Path: logviewer/exc.py
# class AuthenticationError(RuntimeError):
#     pass


# Path: logviewer/auth/langdev.py
import hashlib
import hmac
import json
import requests
from flask import request, current_app, render_template
from .base import AuthBackend
from ..exc import AuthenticationError

# -*- coding: utf-8 -*-



class LangDevAuth(AuthBackend):
    def __init__(self, app_key=None, secret_key=None):
        self._app_key = app_key
        self._secret_key = secret_key

    def login(self, error=None):
        return render_template('auth/basic.html', error=error,
                               next=request.args.get('next'))

    def authenticate(self):
        auth = self.langdev_sso_call(request.form['username'],
                                     request.form['password'])
        if auth:
            return {
                'username': request.form['username'],
            }
        else:

            raise AuthenticationError()