Skip to content

Commit e7bfe0b

Browse files
committed
fix: restore accidentally deleted configuration fields in default.yml
1 parent 5dd5278 commit e7bfe0b

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

app/service/auth_svc.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ async def apply(self, app, users):
7373
for username, password in user.items():
7474
await self.create_user(username, password, group)
7575
app.user_map = self.user_map
76-
77-
# --- START CUSTOM SESSION PERSISTENCE LOGIC --- DBC
78-
raw_session_key = self.get_config('session_cookie_key')
76+
raw_session_key = self.get_config('session_cookie_key')
7977
expiration_days = self.get_config('session_expiration_days')
8078

8179
# Safely calculate max_age in seconds, allowing for fractional days
@@ -85,8 +83,15 @@ async def apply(self, app, users):
8583
max_age = None
8684

8785
if raw_session_key:
88-
# Pad or truncate the string to exactly 32 bytes for the AES cipher
89-
secret_key = str(raw_session_key).encode('utf-8').ljust(32, b'\0')[:32]
86+
try:
87+
# Pad or truncate the string to exactly 32 bytes for the AES cipher; decode as base64
88+
secret_key = base64.b64decode(str(raw_session_key), validate=True)
89+
self.log.debug('Using persistent session cookie key from config.')
90+
except Exception:
91+
self.log.exception('Invalid session cookie key provided in config. Falling back to random key.')
92+
secret_key = str(raw_session_key).encode('utf-8')
93+
94+
secret_key = secret_key.ljust(32, b'\0')[:32]
9095
self.log.debug('Using persistent session cookie key from config.')
9196
else:
9297
# Fallback to the original Caldera behavior (random key on startup)
@@ -96,8 +101,6 @@ async def apply(self, app, users):
96101

97102
# Pass max_age to the storage initializer
98103
storage = EncryptedCookieStorage(secret_key, cookie_name=COOKIE_SESSION, max_age=max_age)
99-
# --- END CUSTOM SESSION PERSISTENCE LOGIC --- DBC
100-
101104
setup_session(app, storage)
102105
policy = SessionIdentityPolicy()
103106
setup_security(app, policy, DictionaryAuthorizationPolicy(self.user_map))

conf/default.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,35 @@ api_key_blue: BLUEADMIN123
33
api_key_red: ADMIN123
44
app.contact.dns.domain: mycaldera.caldera
55
app.contact.dns.socket: 0.0.0.0:8853
6-
app.contact.ftp.host: 0.0.0.0
7-
app.contact.ftp.port: 2222
8-
app.contact.ftp.pword: caldera
9-
app.contact.ftp.server.dir: ftp_dir
10-
app.contact.ftp.user: caldera_user
116
app.contact.gist: API_KEY
127
app.contact.html: /weather
138
app.contact.http: http://0.0.0.0:8888
149
app.contact.slack.api_key: SLACK_TOKEN
1510
app.contact.slack.bot_id: SLACK_BOT_ID
1611
app.contact.slack.channel_id: SLACK_CHANNEL_ID
17-
app.contact.tcp: 0.0.0.0:7010
1812
app.contact.tunnel.ssh.host_key_file: REPLACE_WITH_KEY_FILE_PATH
1913
app.contact.tunnel.ssh.host_key_passphrase: REPLACE_WITH_KEY_FILE_PASSPHRASE
2014
app.contact.tunnel.ssh.socket: 0.0.0.0:8022
2115
app.contact.tunnel.ssh.user_name: sandcat
2216
app.contact.tunnel.ssh.user_password: s4ndc4t!
17+
app.contact.ftp.host: 0.0.0.0
18+
app.contact.ftp.port: 2222
19+
app.contact.ftp.pword: caldera
20+
app.contact.ftp.server.dir: ftp_dir
21+
app.contact.ftp.user: caldera_user
22+
app.contact.tcp: 0.0.0.0:7010
2323
app.contact.udp: 0.0.0.0:7011
2424
app.contact.websocket: 0.0.0.0:7012
25-
auth.login.handler.module: default
25+
objects.planners.default: atomic
2626
crypt_salt: REPLACE_WITH_RANDOM_VALUE
2727
encryption_key: ADMIN123
28-
session_cookie_key: REPLACE_WITH_RANDOM_VALUE #persistent cookie key for sessions, should be a random value and kept secret -DBC
29-
session_expiration_days: 7 #Number of days before a session expires, should be set to a reasonable value and not too long or short. Edge cases show too short requires browser refresh. -DBC
28+
session_cookie_key: REPLACE_WITH_RANDOM_VALUE
29+
session_expiration_days: 7
3030
exfil_dir: /tmp/caldera
31+
reachable_host_traits:
32+
- remote.host.fqdn
33+
- remote.host.ip
3134
host: 0.0.0.0
32-
objects.planners.default: atomic
3335
plugins:
3436
- access
3537
- atomic
@@ -42,10 +44,8 @@ plugins:
4244
- stockpile
4345
- training
4446
port: 8888
45-
reachable_host_traits:
46-
- remote.host.fqdn
47-
- remote.host.ip
4847
reports_dir: /tmp
48+
auth.login.handler.module: default
4949
requirements:
5050
go:
5151
command: go version

0 commit comments

Comments
 (0)