Issue #456: Use of Django connection name rather than alias as lookup#458
Open
sdether wants to merge 2 commits intoexplorerhq:masterfrom
Open
Issue #456: Use of Django connection name rather than alias as lookup#458sdether wants to merge 2 commits intoexplorerhq:masterfrom
sdether wants to merge 2 commits intoexplorerhq:masterfrom
Conversation
… as lookup This commit changes connection behavior from storing the database connection name to using the database alias mapped by SQL Explorer instead. The reason for this change is two-fold: 1) Views take the connection name as input, allowing anyone who knows Django connection names to query those databases, even if SQL does not expose the connection directly. 2) `Query` stores the connection name, which means that if the Django connection name changes or a different connection should be used (for example, one with reduced permissions) the stored Query will either stop working or at least continue using the old connection This change modifies `ExplorerConnections` from being a dictionary that proxies the Django connection dictionary to a dictionary-like object that uses `EXPLORER_CONNECTIONS` to lookup and validate the requested connection alias. In addition all code that used to the `EXPLORER_CONNECTIONS` value now uses the key instead. For backwards compatibility, a migration will back-populate the alias into `Query` instances (and fail if the mapping no longer exists), `EXPLORER_DEFAULT_CONNECTION` is re-written on start-up to use the alias in case it still uses the Django Connection name and `ExplorerConnections` will still accept a Django Connection name as long as that name is exposed by some alias in `EXPLORER_CONNECTIONS`.
marksweb
previously approved these changes
Jan 10, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit changes connection behavior from storing the database
connection name to using the database alias mapped by SQL Explorer
instead.
The reason for this change is two-fold:
Django connection names to query those databases, even if SQL
does not expose the connection directly.
Querystores the connection name, which means that if theDjango connection name changes or a different connection should
be used (for example, one with reduced permissions) the stored
Query will either stop working or at least continue using the old
connection
This change modifies
ExplorerConnectionsfrom being a dictionarythat proxies the Django connection dictionary to a dictionary-like
object that uses
EXPLORER_CONNECTIONSto lookup and validatethe requested connection alias.
In addition all code that used to the
EXPLORER_CONNECTIONSvaluenow uses the key instead.
For backwards compatibility, a migration will back-populate the alias
into
Queryinstances (and fail if the mapping no longer exists),EXPLORER_DEFAULT_CONNECTIONis re-written on start-up to use thealias in case it still uses the Django Connection name and
ExplorerConnectionswill still accept a Django Connection name aslong as that name is exposed by some alias in
EXPLORER_CONNECTIONS.