Skip to content

Commit

Permalink
block when secret-key is too short (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucabello authored Aug 13, 2024
1 parent c1a3ac6 commit a85ad55
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 a85ad55

Please sign in to comment.