Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
ldap-auth
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shore
ldap-auth
Commits
6f44b4b0
Commit
6f44b4b0
authored
4 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
First draft.
Depends on my fork of flask-simpleldap.
parent
84d359c6
No related branches found
No related tags found
No related merge requests found
Pipeline
#1137
passed
4 years ago
Stage: test
Stage: build
Stage: deploy
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.dockerignore
+2
-0
2 additions, 0 deletions
.dockerignore
Dockerfile
+12
-6
12 additions, 6 deletions
Dockerfile
README.md
+7
-0
7 additions, 0 deletions
README.md
app.py
+51
-0
51 additions, 0 deletions
app.py
requirements.txt
+4
-0
4 additions, 0 deletions
requirements.txt
with
76 additions
and
6 deletions
.dockerignore
+
2
−
0
View file @
6f44b4b0
*
!app.py
!requirements.txt
This diff is collapsed.
Click to expand it.
Dockerfile
+
12
−
6
View file @
6f44b4b0
...
...
@@ -3,11 +3,13 @@ FROM registry.hub.docker.com/library/python:3.9-slim-buster as wheels
RUN
apt-get update
&&
\
DEBIAN_FRONTEND
=
noninteractive apt-get
install
-y
\
build-essential
\
git
\
libldap2-dev
\
libsasl2-dev
\
;
WORKDIR
/wheels
RUN
python3
-m
pip wheel https://github.com/python-ldap/python-ldap/releases/download/python-ldap-3.3.1/python-ldap-3.3.1.tar.gz
RUN
python3
-m
pip wheel git+https://github.com/adarnimrod/flask-simpleldap.git@ldapi-support#egg
=
flask-simpleldap
FROM
registry.hub.docker.com/library/python:3.9-slim-buster
# hadolint ignore=DL3008
...
...
@@ -15,13 +17,17 @@ RUN apt-get update && \
DEBIAN_FRONTEND
=
noninteractive apt-get
install
-y
--no-install-recommends
\
libldap-2.4-2
\
libsasl2-2
\
wget
\
&&
\
rm
-rf
/tmp/
*
/var/tmp/
*
/var/lib/apt/lists/
*
/var/cache/apt/archives/
*
COPY
--from=wheels /wheels/*.whl /wheels/
RUN
pip
install
/wheels/
*
.whl
# hadolint ignore=DL3013
RUN
pip
install
--no-cache-dir
\
flask
\
flask-ldap
\
gunicorn
\
;
WORKDIR
/app
COPY
requirements.txt ./
RUN
pip
install
--no-cache-dir
-r
requirements.txt
COPY
* ./
USER
nobody
EXPOSE
8080
ENV
FORWARDED_ALLOW_IPS "*"
HEALTHCHECK
CMD wget --spider --quiet http://localhost:8080/ping --user-agent 'Docker Healthcheck' || exit 1
CMD
["gunicorn", "--bind", "0.0.0.0:8080", "--log-file", "-", "--workers", "2", "app:app"]
This diff is collapsed.
Click to expand it.
README.md
+
7
−
0
View file @
6f44b4b0
...
...
@@ -4,6 +4,13 @@
LDAP authentication webserver to use with Nginx' auth
\_
request.
## Configuration
All of the configuration is done with environment variables. For the
complete list see
<https://flask-simpleldap.readthedocs.io/en/latest/#configuration>
and
<https://flask.palletsprojects.com/en/1.1.x/config/#configuring-from-environment-variables>
.
## License
This software is licensed under the MIT license (see
`LICENSE.txt`
).
...
...
This diff is collapsed.
Click to expand it.
app.py
0 → 100644
+
51
−
0
View file @
6f44b4b0
"""
LDAP authentication webserver to use with Nginx
'
auth_request.
"""
# pylint: disable=import-error
import
os
from
flask
import
Flask
from
flask_simpleldap
import
LDAP
app
=
Flask
(
__name__
)
app
.
config
[
"
SECRET_KEY
"
]
=
os
.
getenv
(
"
SECRET_KEY
"
,
os
.
urandom
(
16
))
app
.
config
[
"
LDAP_SCHEMA
"
]
=
os
.
getenv
(
"
LDAP_SCHEMA
"
,
"
ldapi
"
)
app
.
config
[
"
LDAP_HOST
"
]
=
os
.
getenv
(
"
LDAP_HOST
"
,
"
localhost
"
)
app
.
config
[
"
LDAP_PORT
"
]
=
int
(
os
.
getenv
(
"
LDAP_PORT
"
,
"
389
"
))
app
.
config
[
"
LDAP_USERNAME
"
]
=
os
.
getenv
(
"
LDAP_USERNAME
"
)
app
.
config
[
"
LDAP_PASSWORD
"
]
=
os
.
getenv
(
"
LDAP_PASSWORD
"
)
app
.
config
[
"
LDAP_USE_TLS
"
]
=
(
os
.
getenv
(
"
LDAP_USE_TLS
"
,
"
false
"
).
lower
()
==
"
true
"
)
app
.
config
[
"
LDAP_REQUIRE_CERT
"
]
=
(
os
.
getenv
(
"
LDAP_REQUIRE_CERT
"
,
"
false
"
).
lower
()
==
"
true
"
)
app
.
config
[
"
LDAP_BASE_DN
"
]
=
os
.
getenv
(
"
LDAP_BASE_DN
"
)
app
.
config
[
"
LDAP_REALM_NAME
"
]
=
os
.
getenv
(
"
LDAP_REALM_NAME
"
,
"
LDAP authentication
"
)
app
.
config
[
"
LDAP_OPENLDAP
"
]
=
(
os
.
getenv
(
"
LDAP_OPENLDAP
"
,
"
false
"
).
lower
()
==
"
true
"
)
app
.
config
[
"
LDAP_OBJECTS_DN
"
]
=
os
.
getenv
(
"
LDAP_OBJECTS_DN
"
,
"
distinguishedName
"
)
app
.
config
[
"
LDAP_USER_OBJECT_FILTER
"
]
=
os
.
getenv
(
"
LDAP_USER_OBJECT_FILTER
"
,
"
(&(objectclass=Person)(userPrincipalName=%s))
"
)
ldap
=
LDAP
(
app
)
@app.route
(
"
/ping
"
)
def
ping
():
"""
Healthcheck.
"""
return
"
pong
"
@app.route
(
"
/validate
"
)
@ldap.basic_auth_required
def
login
():
return
"
OK
"
if
__name__
==
"
__main__
"
:
app
.
run
()
This diff is collapsed.
Click to expand it.
requirements.txt
0 → 100644
+
4
−
0
View file @
6f44b4b0
flask
flask-simpleldap
gunicorn
python-ldap
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment