Skip to content

Commit

Permalink
Merge pull request #195 from canonical/kf-6057-backport-secret-key-le…
Browse files Browse the repository at this point in the history
…ngth

backport(fix): block when secret-key is too short from #178
  • Loading branch information
orfeas-k authored Nov 20, 2024
2 parents e107f30 + 4814315 commit 151d43d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ options:
secret-key:
type: string
default: ''
description: Secret key
description: Secret key. Must be at least 8 characters long. If not provided, a random key will be used.
mode:
type: string
default: 'server'
Expand Down
7 changes: 7 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def main(self, event):
return

secret_key = self._get_secret_key()

if len(secret_key) < 8:
self.model.unit.status = BlockedStatus(
"The `secret-key` config value must be at least 8 characters long."
)
return

self._send_info(interfaces, secret_key)

configmap_hash = self._generate_config_hash()
Expand Down

0 comments on commit 151d43d

Please sign in to comment.