Skip to content

Conversation

@UFOSmuggler
Copy link
Contributor

@UFOSmuggler UFOSmuggler commented Dec 2, 2025

This closes #344 by checking whether or not a valid auth key exists for user 1.

We do SELECT EXISTS(SELECT 1 FROM auth_keys WHERE user_id = 1 AND (expiration = 0 OR expiration > UNIX_TIMESTAMP())); which checks for non-expiring and non-expired auth keys for user 1, and returns 0 or 1 based on whether there is a valid auth key.

If there is a valid auth key, we skip regeneration and emit a log line.

There appears to be no cake console command to check the existence of a valid auth key (we can test keys, but not see if a valid one exists) so checking the DB seems to be the way to go.

valid key exists:

misp-core-1  | Enforcing initialisation setting 'MISP.contact' to env var or default value 'admin@admin.test'...
misp-core-1  | Enforcing initialisation setting 'MISP.email' to env var or default value 'admin@admin.test'...
misp-core-1  | Enforcing gpg setting 'GnuPG.email' to env var or default value 'admin@admin.test'...
misp-core-1  | ... valid admin key for admin user found, not changing

no valid key exists:

misp-core-1  | Enforcing initialisation setting 'MISP.contact' to env var or default value 'admin@admin.test'...
misp-core-1  | Enforcing initialisation setting 'MISP.email' to env var or default value 'admin@admin.test'...
misp-core-1  | Enforcing gpg setting 'GnuPG.email' to env var or default value 'admin@admin.test'...
misp-core-1  | ... regenerating admin key (set $ADMIN_KEY if you want it to change)
misp-core-1  | ... admin user key set to 'UeIKSNF8X2oQ1FFGA3Xxvdwt4NKqJIO3vH6n6HpD'

@ostefano ostefano self-assigned this Dec 3, 2025
@ostefano ostefano merged commit 157aebc into MISP:master Dec 3, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Existing auth keys reset to expired after container restart

2 participants