Skip to content

Commit

Permalink
Merge pull request #169 from Progress1/bug_ldap
Browse files Browse the repository at this point in the history
Fixed bugs from last PR
  • Loading branch information
milankowww authored Oct 1, 2023
2 parents f710697 + 15371f0 commit 09c9ec7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions docker/Dockerfile.publishers
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN pip install --no-cache-dir ./custom_packages/taranis_ng_shared-*.whl && rm -
COPY ./src/publishers/requirements.txt /app/requirements.txt
RUN apk add --no-cache \
swig\
libmagic \
gnupg

RUN \
Expand Down
1 change: 1 addition & 0 deletions src/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ If you prefer to authenticate users with LDAP, you need to set environment varia
TARANIS_NG_AUTHENTICATOR: "ldap"
LDAP_SERVER: "ldaps://ldap.example.com"
LDAP_BASE_DN: "ou=people,dc=example,dc=com"
LDAP_CA_CERT_PATH: "auth/ldap_ca.pem"
```
4 changes: 2 additions & 2 deletions src/core/auth/ldap_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class LDAPAuthenticator(BaseAuthenticator):

LDAP_SERVER = os.getenv('LDAP_SERVER')
LDAP_BASE_DN = os.getenv('LDAP_BASE_DN')
LDAP_CA_CERT_PATH = 'auth/ldap_ca.pem'
if not os.path.isfile(LDAP_CA_CERT_PATH):
LDAP_CA_CERT_PATH = os.getenv('LDAP_CA_CERT_PATH')
if LDAP_CA_CERT_PATH is not None and not os.path.isfile(LDAP_CA_CERT_PATH):
LDAP_CA_CERT_PATH = None
log_manager.store_auth_error_activity("No LDAP CA certificate found. LDAP authentication might not work.")

Expand Down
6 changes: 4 additions & 2 deletions src/core/managers/auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def initialize(app):

JWTManager(app)

which = os.getenv('TARANIS_NG_AUTHENTICATOR').casefold()
which = os.getenv('TARANIS_NG_AUTHENTICATOR')
if which is not None:
which = which.lower()
if which == 'openid':
current_authenticator = OpenIDAuthenticator()
elif which == 'keycloak':
Expand Down Expand Up @@ -271,7 +273,7 @@ def wrapper(*args, **kwargs):
error = ({'error': 'not authorized'}, 401)

# do we have the authorization header?
if 'Authorization' not in request.headers.has_key:
if 'Authorization' not in request.headers:
log_manager.store_auth_error_activity("Missing Authorization header for external access")
return error

Expand Down

0 comments on commit 09c9ec7

Please sign in to comment.