Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed Configuration class #6682

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from redash.utils.configuration import ConfigurationContainer
from redash.models.types import (
EncryptedConfiguration,
Configuration,
MutableDict,
MutableList,
)
Expand Down Expand Up @@ -45,7 +44,14 @@ def upgrade():
)
),
),
sa.Column("options", ConfigurationContainer.as_mutable(Configuration)),
sa.Column(
"options",
ConfigurationContainer.as_mutable(
EncryptedConfiguration(
sa.Text, settings.DATASOURCE_SECRET_KEY, FernetEngine
)
),
),
)

conn = op.get_bind()
Expand Down
14 changes: 9 additions & 5 deletions migrations/versions/d7d747033183_encrypt_alert_destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
from redash import settings
from redash.utils.configuration import ConfigurationContainer
from redash.models.base import key_type
from redash.models.types import (
EncryptedConfiguration,
Configuration,
)
from redash.models.types import EncryptedConfiguration


# revision identifiers, used by Alembic.
Expand Down Expand Up @@ -45,7 +42,14 @@ def upgrade():
)
),
),
sa.Column("options", ConfigurationContainer.as_mutable(Configuration)),
sa.Column(
"options",
ConfigurationContainer.as_mutable(
EncryptedConfiguration(
sa.Text, settings.DATASOURCE_SECRET_KEY, FernetEngine
)
),
),
)

conn = op.get_bind()
Expand Down
1 change: 0 additions & 1 deletion redash/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
QueryDetachedFromDataSourceError,
)
from redash.models.types import (
Configuration,
EncryptedConfiguration,
JSONText,
MutableDict,
Expand Down
13 changes: 1 addition & 12 deletions redash/models/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@
from sqlalchemy.types import TypeDecorator
from sqlalchemy_utils import EncryptedType

from redash.models.base import db
from redash.utils import json_dumps, json_loads
from redash.utils.configuration import ConfigurationContainer

from .base import db


class Configuration(TypeDecorator):
impl = db.Text

def process_bind_param(self, value, dialect):
return value.to_json()

def process_result_value(self, value, dialect):
return ConfigurationContainer.from_json(value)


class EncryptedConfiguration(EncryptedType):
def process_bind_param(self, value, dialect):
Expand Down
Loading