Skip to content

Commit cd9262d

Browse files
committed
migrated some of files to docker folder
1 parent a83a6e7 commit cd9262d

File tree

8 files changed

+34
-14
lines changed

8 files changed

+34
-14
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ lemur/static/dist
99
node_modules
1010
bower_components
1111
.tmp
12-
migrations

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ RUN useradd --create-home --shell /bin/bash lemur
6363
COPY --from=builder --chown=lemur:lemur /opt/lemur /opt/lemur
6464

6565
# Ensure entrypoint is executable
66-
RUN chmod +x /opt/lemur/entrypoint
66+
RUN chmod +x /opt/lemur/docker/entrypoint.sh
6767

6868
# Switch to the user
6969
USER lemur
@@ -72,4 +72,4 @@ USER lemur
7272
EXPOSE 80
7373

7474
# Default command
75-
ENTRYPOINT ["/opt/lemur/entrypoint"]
75+
ENTRYPOINT ["/opt/lemur/docker/entrypoint.sh"]
File renamed without changes.

entrypoint renamed to docker/entrypoint.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
set -e
33

44
echo "[supervisor] Starting Lemur container..."
5-
install -Dm644 /opt/lemur/lemur.conf.py /home/lemur/.lemur/lemur.conf.py
65

76
cd /opt/lemur
87

@@ -26,4 +25,4 @@ LEMUR_PID=$!
2625
trap 'echo "[supervisor] Caught stop signal"; kill "$LEMUR_PID" "$CADDY_PID" 2>/dev/null || true' SIGTERM SIGINT
2726

2827
echo "[supervisor] Starting Caddy (foreground)..."
29-
exec caddy run --config /opt/lemur/Caddyfile
28+
exec caddy run --config /opt/lemur/docker/Caddyfile

generate_tokens.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
"""
22
Helper script to generate random values for Lemur configuration
33
"""
4-
from base64 import urlsafe_b64encode, b64encode
4+
5+
import secrets
6+
import string
7+
from base64 import b64encode, urlsafe_b64encode
58
from os import urandom
69
from secrets import choice, token_hex
710
from string import ascii_lowercase, ascii_uppercase, digits
11+
from time import time
12+
13+
from cryptography.hazmat.primitives import hashes, hmac
814

915
chars = ascii_uppercase + ascii_lowercase + digits + "~!@#$%^&*()_+"
1016

17+
18+
def get_random_secret(length):
19+
"""Similar to get_pseudo_random_string, but accepts a length parameter."""
20+
return "".join(secrets.choice(chars) for x in range(length))
21+
22+
23+
def generate_state_token():
24+
t = int(time())
25+
ts = hex(t)[2:].encode("ascii")
26+
h = hmac.HMAC(b64encode(get_random_secret(32).encode("utf8")), hashes.SHA256())
27+
h.update(ts)
28+
digest = b64encode(h.finalize())
29+
state = ts + b":" + digest
30+
return state.decode()
31+
32+
1133
print("LEMUR_ENCRYPTION_KEY:", urlsafe_b64encode(urandom(32)).decode())
12-
print("LEMUR_TOKEN_SECRET:", ''.join(choice(chars) for x in range(24)))
34+
print("LEMUR_TOKEN_SECRET:", "".join(choice(chars) for x in range(24)))
1335
print("SECRET:", token_hex())
1436
print("OAUTH2_SECRET:", token_hex())
15-
print("OAUTH_STATE_TOKEN_SECRET:", b64encode(urandom(32)))
37+
print("OAUTH_STATE_TOKEN_SECRET:", generate_state_token())

lemur.conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
# You should consider storing these separately from your config
3030
LEMUR_TOKEN_SECRET = "EO5vLI6sBXBLKDJr_2AYYq"
3131
LEMUR_TOKEN_SECRETS = [LEMUR_TOKEN_SECRET]
32-
LEMUR_ENCRYPTION_KEYS = ['Q7AzDsZHJRaKdS4Obeb4bLw6tYRdTqQD24xHQqJbA4A=']
32+
LEMUR_ENCRYPTION_KEYS = ["Q7AzDsZHJRaKdS4Obeb4bLw6tYRdTqQD24xHQqJbA4A="]
3333

3434

35-
OAUTH2_SECRET = 'd105a7b3f365423a08917fa0455b353fce966e955c3a6e88f8ff149fac301a03'
35+
OAUTH2_SECRET = "d105a7b3f365423a08917fa0455b353fce966e955c3a6e88f8ff149fac301a03"
3636

3737
# this is the secret used to generate oauth state tokens
38-
OAUTH_STATE_TOKEN_SECRET = b'jhyNmgizEixQRnWL8F9yTfGlKz3pp2ks2GGxAUoFYE8='
38+
OAUTH_STATE_TOKEN_SECRET = "693e7b68:VY7FS2WY13LQU2n6iBkCo3i7jpKBkyjNU7sQEZz5fXg="
3939

4040
# REQUIRED
4141
# Certificate Defaults
@@ -66,7 +66,7 @@
6666

6767

6868
# Database settings
69-
SQLALCHEMY_DATABASE_URI = environ.get('SQLALCHEMY_DATABASE_URI', 'postgresql://lemur:lemur@localhost:5432/lemur')
69+
SQLALCHEMY_DATABASE_URI = environ.get("SQLALCHEMY_DATABASE_URI", "postgresql://lemur:lemur@localhost:5432/lemur")
7070
# SQLALCHEMY_ENABLE_FLASK_REPLICATED = False
7171
# SQLALCHEMY_TRACK_MODIFICATIONS = False
7272
# SQLALCHEMY_ECHO = True

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ dependencies = [
6969
"idna==3.7",
7070
"importlib-resources==6.4.0",
7171
"inflection==0.5.1",
72-
"invoke==2.2.0",
72+
"invoke>=2.2.0",
7373
"itsdangerous==2.2.0",
7474
"javaobj-py3==0.4.4",
7575
"jinja2==3.1.6",

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)