Skip to content

feat: support storing, retrieving and refreshing encrypted secrets at account or asset level#2236

Open
nhoening wants to merge 26 commits into
mainfrom
feat/secrets-column
Open

feat: support storing, retrieving and refreshing encrypted secrets at account or asset level#2236
nhoening wants to merge 26 commits into
mainfrom
feat/secrets-column

Conversation

@nhoening

@nhoening nhoening commented Jun 13, 2026

Copy link
Copy Markdown
Member

Description

With this PR, secrets like refresh and access tokens can be stored on account or asset level in the db (encrypted).
This allows to stop saving them in configuration files as-is. This PR also adds supporting logic which manages token refresh cycles.

  • db migration for secrets field on account and asset level
  • Add secret utils for getting and setting encrypted secrets
  • also support token refresh operations
  • document this support
  • add CLI commands flexmeasures edit secret and flexmeasures delete secret
  • display secret meta info on account and asset properties page
  • Added changelog item in documentation/changelog.rst

Look & Feel

View of secrets shown in the UI:

Screenshot from 2026-06-18 17-48-10

How to test

I tested this in a plugin which connects to 3rd party platforms, by adding code which integrated with these new fields and utils. I added a login CLI command there, plus get_3rdparty_platform_access_token() helpers and explicit warnigns and errors.

Further Improvements

… account or asset level

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening nhoening added this to the 1.0.0 milestone Jun 13, 2026
@nhoening nhoening self-assigned this Jun 13, 2026
nhoening added 2 commits June 14, 2026 01:29
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…on initialiation there

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening nhoening requested a review from Flix6x June 14, 2026 00:48

@Flix6x Flix6x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably some discussion points before proceeding?

Comment thread documentation/configuration.rst Outdated
Comment thread documentation/changelog.rst
Comment thread documentation/plugin/storing-platform-secrets.rst Outdated
Comment thread documentation/plugin/storing-platform-secrets.rst Outdated
Comment thread documentation/plugin/storing-platform-secrets.rst Outdated
Comment thread documentation/dev/connection-secrets.rst Outdated
Comment thread documentation/dev/connection-secrets.rst Outdated
Comment thread documentation/dev/connection-secrets.rst Outdated
Comment thread documentation/dev/connection-secrets.rst Outdated
Comment thread documentation/dev/connection-secrets.rst Outdated

@Flix6x Flix6x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking that this PR might need CLI logic to rotate the FLEXMEASURES_SECRETS_ENCRYPTION_KEY key, updating secrets accordingly. That is, decrypting secrets that were encrypted using the old key, and encrypting them with the new key.

@nhoening

Copy link
Copy Markdown
Member Author

I was also thinking that this PR might need CLI logic to rotate the FLEXMEASURES_SECRETS_ENCRYPTION_KEY key, updating secrets accordingly. That is, decrypting secrets that were encrypted using the old key, and encrypting them with the new key.

I would suggest doing a follow-up PR for that.

nhoening added 6 commits June 17, 2026 17:23
…ove plugin docs section

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening nhoening requested a review from Flix6x June 18, 2026 14:52
nhoening added 2 commits June 18, 2026 17:33
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Comment thread documentation/cli/change_log.rst Outdated
Comment thread documentation/cli/commands.rst Outdated
Comment thread documentation/cli/commands.rst Outdated
Comment thread documentation/configuration.rst Outdated
Comment thread documentation/plugin/storing-platform-secrets.rst Outdated
Comment thread flexmeasures/cli/data_edit.py Outdated
Comment thread flexmeasures/cli/data_edit.py Outdated
Comment thread flexmeasures/cli/data_edit.py Outdated
"--secret",
"secret_path",
required=True,
help="Add/edit this secret. Follow up with a dot-separated path.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the dot-separated path do?

Comment thread flexmeasures/cli/data_edit.py
nhoening and others added 9 commits June 22, 2026 12:53
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
nhoening and others added 6 commits June 22, 2026 13:25
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
Signed-off-by: Nicolas Höning <iam@nicolashoening.de>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants