Skip to content

Commit

Permalink
Added logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Dumay committed Aug 1, 2017
1 parent 510cbad commit c46dc96
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.0.10
0.0.11
6 changes: 5 additions & 1 deletion src/flask_graylog_bundle/auth.py
Expand Up @@ -6,6 +6,7 @@
"""
import logging
import re

from flask import g, request
Expand All @@ -15,6 +16,8 @@

from flask_graylog_bundle import GraylogExt, MESSAGE_MAP

logger = logging.getLogger(__name__)


class GraylogAuth(GraylogExt):
def login_required(self, func):
Expand Down Expand Up @@ -47,9 +50,10 @@ def username(self):
@staticmethod
def authenticate():
"""Sends a 401 response"""
logger.error(MESSAGE_MAP["AuthenticationFailed"])
raise Unauthorized(
message=MESSAGE_MAP["AuthenticationFailed"],
extra=dict(factory="graylog-auth", msgid="AuthenticationFailed")
extra=dict(msgid="AuthenticationFailed")
)

def load_user_info(self):
Expand Down
5 changes: 4 additions & 1 deletion src/flask_graylog_bundle/server.py
Expand Up @@ -6,11 +6,13 @@
"""
import logging
from cdumay_rest_client.exceptions import NotFound, ValidationError
from flask_graylog_bundle import GraylogExt, MESSAGE_MAP
from cdumay_rest_client.client import RESTClient
from flask_graylog_bundle import validators

logger = logging.getLogger(__name__)


class GraylogAPIServer(GraylogExt):
Expand Down Expand Up @@ -91,9 +93,10 @@ def user_is_admin(self, username):

def user_set_password(self, username, password):
if password in ("", None):
logger.error(MESSAGE_MAP["PasswordNull"])
raise ValidationError(
message=MESSAGE_MAP["PasswordNull"],
extra=dict(factory="graylog-auth", msgid="PasswordNull")
extra=dict(msgid="PasswordNull")
)
return self._update(
spath=['users', username, 'password'],
Expand Down

0 comments on commit c46dc96

Please sign in to comment.