This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Refactor strategy instantiation for more extensitiliby #1254
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
88aec8f
Instantiate strategies via abstract Strategy base class
991a2e0
Update get_description() to be a class rather than static method
6cf919a
Remove strategy factories and update references
a8ceb2d
Remove strategy name constants
7204d11
Remove get_configuration_model() abstract method
244d67d
Update MaskingStrategy docs with new Strategy functionality
d3221ec
Update changelog
44ece6b
Improve recursion in _find_all_strategy_subclasses
c8001aa
Fix recursion bug when finding all strategies
6ed4701
Tweak conditional for falsy check
393814e
Make get_strategies endpoint test more robust
48ecfa0
Fix typo in documentation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from fidesops.ops.service.authentication import ( | ||
authentication_strategy_basic, | ||
authentication_strategy_bearer, | ||
authentication_strategy_oauth2_authorization_code, | ||
authentication_strategy_oauth2_client_credentials, | ||
authentication_strategy_query_param, | ||
) |
11 changes: 3 additions & 8 deletions
11
src/fidesops/ops/service/authentication/authentication_strategy.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
from abc import ABC, abstractmethod | ||
from abc import abstractmethod | ||
|
||
from requests import PreparedRequest | ||
|
||
from fidesops.ops.models.connectionconfig import ConnectionConfig | ||
from fidesops.ops.schemas.saas.strategy_configuration import StrategyConfiguration | ||
from fidesops.ops.service.strategy import Strategy | ||
|
||
|
||
class AuthenticationStrategy(ABC): | ||
class AuthenticationStrategy(Strategy): | ||
"""Abstract base class for SaaS authentication strategies""" | ||
|
||
@abstractmethod | ||
def add_authentication( | ||
self, request: PreparedRequest, connection_config: ConnectionConfig | ||
) -> PreparedRequest: | ||
"""Add authentication to the request""" | ||
|
||
@staticmethod | ||
@abstractmethod | ||
def get_configuration_model() -> StrategyConfiguration: | ||
"""Used to get the configuration model to configure the strategy""" |
This file contains 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
This file contains 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
78 changes: 0 additions & 78 deletions
78
src/fidesops/ops/service/authentication/authentication_strategy_factory.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it OK to edit this file by hand? i hesitated before doing so since it's a generated migration file...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine since it's functionally equivalent, we're just cleaning up the constants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth noting that this file wasn't actually auto-generated either, it's a data migration instead of a schema migration and automatically adds several rows to multiple tables in the fidesops application database!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, nice - thanks for clarifying that @pattisdr!