Skip to content

Commit a5fa67e

Browse files
provide some base class implementations for built-in provider to make life easier for integrators
1 parent 8e3d7a0 commit a5fa67e

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

src/planet_auth_utils/builtins_provider.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ def builtin_client_authclient_config_dicts(self) -> Dict[str, dict]:
5050
`planet_auth.AuthClientConfig.config_from_dict`
5151
"""
5252

53-
@abstractmethod
5453
def builtin_client_profile_aliases(self) -> Dict[str, str]:
5554
"""
5655
Return a dictionary profile aliases. Aliases allow
5756
for a single built-in configuration to be referred to
5857
by multiple names.
5958
"""
59+
return {}
6060

6161
@abstractmethod
6262
def builtin_default_profile_by_client_type(self) -> Dict[str, str]:
@@ -70,18 +70,30 @@ def builtin_default_profile(self) -> str:
7070
Return the built-in default fallback auth profile name of last resort.
7171
"""
7272

73-
@abstractmethod
7473
def builtin_trust_environment_names(self) -> List[str]:
7574
"""
7675
Return a list of the names of built-in trust environments.
7776
"""
77+
_realms = self.builtin_trust_environments()
78+
if _realms:
79+
return list(_realms.keys())
80+
return []
7881

79-
@abstractmethod
8082
def builtin_trust_environments(self) -> Dict[str, Optional[List[dict]]]:
8183
"""
8284
Return a dictionary of the trust environment configurations.
8385
Each item in the lists should be valid AuthClient config dictionary.
86+
87+
This is primarily used for cases where planet_auth is used to validate
88+
tokens on the service side. This is the flip side of most of the other
89+
BuiltinConfigurationProviderInterface methods which are geared towards
90+
helping clients obtain tokens.
8491
"""
92+
return {
93+
# "PRODUCTION": [MY_REALM_PRODUCTION],
94+
# "STAGING": [MY_REALM_STAGING],
95+
"CUSTOM": None,
96+
}
8597

8698

8799
class EmptyBuiltinProfileConstants(BuiltinConfigurationProviderInterface):
@@ -95,29 +107,15 @@ class EmptyBuiltinProfileConstants(BuiltinConfigurationProviderInterface):
95107
BUILTIN_PROFILE_NAME_NONE: NONE_AUTH_CLIENT_CONFIG,
96108
}
97109

98-
_builtin_profile_aliases: Dict[str, str] = {}
99-
100110
_builtin_profile_default_by_client_type = {
101111
"none": BUILTIN_PROFILE_NAME_NONE,
102112
}
103-
_builtin_trust_realms: Dict[str, Optional[List[dict]]] = {
104-
"CUSTOM": None,
105-
}
106113

107114
def builtin_client_authclient_config_dicts(self) -> Dict[str, dict]:
108115
return EmptyBuiltinProfileConstants._builtin_profile_auth_client_configs
109116

110-
def builtin_client_profile_aliases(self) -> Dict[str, str]:
111-
return EmptyBuiltinProfileConstants._builtin_profile_aliases
112-
113117
def builtin_default_profile_by_client_type(self) -> Dict[str, str]:
114118
return EmptyBuiltinProfileConstants._builtin_profile_default_by_client_type
115119

116120
def builtin_default_profile(self) -> str:
117121
return EmptyBuiltinProfileConstants.BUILTIN_PROFILE_NAME_NONE
118-
119-
def builtin_trust_environment_names(self) -> List[str]:
120-
return list(EmptyBuiltinProfileConstants._builtin_trust_realms.keys())
121-
122-
def builtin_trust_environments(self) -> Dict[str, Optional[List[dict]]]:
123-
return EmptyBuiltinProfileConstants._builtin_trust_realms

tests/test_planet_auth_utils/unit/auth_utils/builtins_test_impl.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,5 @@ def builtin_default_profile_by_client_type(self) -> Dict[str, str]:
186186
def builtin_default_profile(self) -> str:
187187
return self.DEFAULT_PROFILE
188188

189-
def builtin_trust_environment_names(self) -> List[str]:
190-
return list(BuiltinConfigurationProviderMockTestImpl._builtin_trust_realms.keys())
191-
192189
def builtin_trust_environments(self) -> Dict[str, Optional[List[dict]]]:
193190
return BuiltinConfigurationProviderMockTestImpl._builtin_trust_realms

0 commit comments

Comments
 (0)