def validate_client_id(self, client_id):
        """Check that the client_id represents a valid application.

        :param client_id: Client id.
        :type client_id: str
        """
        return Application.find(client_id) is not None
    def validate_client_secret(self, client_id, client_secret):
        """Check that the client secret matches the application secret.

        :param client_id: Client Id.
        :type client_id: str
        :param client_secret: Client secret.
        :type client_secret: str
        """
        app = Application.find(client_id)
        if app is not None and app.secret == client_secret:
            return True
        return False
    def validate_redirect_uri(self, client_id, redirect_uri):
        """Validate that the redirect_uri requested is available for the app.

        :param redirect_uri: Redirect URI.
        :type redirect_uri: str
        """

        app = Application.find(client_id)
        # When matching against a redirect_uri, it is very important to 
        # ignore the query parameters, or else this step will fail as the 
        # parameters change with every request
        if app is not None and app.redirect_uri == redirect_uri.split('?')[0]:
            return True
        return False
示例#4
0
def login_post(client_id):
    login = request.form['login']
    password = request.form['password']
    login = Login.find(login)
    if login == None:
        flash('User not found!', 'error')
        return redirect(url_for('.login_get', client_id=client_id))
    p_ok = sha256_crypt.verify(password, login.password)
    if not p_ok:
        flash('Incorect password!', 'error')
        return redirect(url_for('.login_get', client_id=client_id))
    session['user'] = login
    app = Application.find(client_id)
    return redirect(url_for('.authorization_code', client_id=client_id,
                    redirect_uri=app.redirect_uri, response_type='code'))
示例#5
0