-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refactoring code to get oidc end points from discovery URL. (#4429
) * refactoring the permissions side server side code to get the OIDC end points from the discovery URL. Also removing the auth_server_url config from oidc auth config. Signed-off-by: Lokesh Rangineni <[email protected]> * refactoring the permissions side server side code to get the OIDC end points from the discovery URL. Also removing the auth_server_url config from oidc auth config. Signed-off-by: Lokesh Rangineni <[email protected]> * refactoring the permissions side server side code to get the OIDC end points from the discovery URL. Also removing the auth_server_url config from oidc auth config. Signed-off-by: Lokesh Rangineni <[email protected]> * refactoring the permissions side server side code to get the OIDC end points from the discovery URL. Also removing the auth_server_url config from oidc auth config. Signed-off-by: Lokesh Rangineni <[email protected]> * Fixing the issue with pre-commit hook template. Accidentally this was reverted in previous rebase and reverting it now. Signed-off-by: Lokesh Rangineni <[email protected]> --------- Signed-off-by: Lokesh Rangineni <[email protected]>
- Loading branch information
1 parent
dda0088
commit 896360a
Showing
12 changed files
with
73 additions
and
35 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import requests | ||
|
||
|
||
class OIDCDiscoveryService: | ||
def __init__(self, discovery_url: str): | ||
self.discovery_url = discovery_url | ||
self._discovery_data = None # Initialize it lazily. | ||
|
||
@property | ||
def discovery_data(self): | ||
"""Lazily fetches and caches the OIDC discovery data.""" | ||
if self._discovery_data is None: | ||
self._discovery_data = self._fetch_discovery_data() | ||
return self._discovery_data | ||
|
||
def _fetch_discovery_data(self) -> dict: | ||
try: | ||
response = requests.get(self.discovery_url) | ||
response.raise_for_status() | ||
return response.json() | ||
except requests.RequestException as e: | ||
raise RuntimeError( | ||
f"Error fetching OIDC discovery response, discovery url - {self.discovery_url}, exception - {e} " | ||
) | ||
|
||
def get_authorization_url(self) -> str: | ||
"""Returns the authorization endpoint URL.""" | ||
return self.discovery_data.get("authorization_endpoint") | ||
|
||
def get_token_url(self) -> str: | ||
"""Returns the token endpoint URL.""" | ||
return self.discovery_data.get("token_endpoint") | ||
|
||
def get_jwks_url(self) -> str: | ||
"""Returns the jwks endpoint URL.""" | ||
return self.discovery_data.get("jwks_uri") | ||
|
||
def get_refresh_url(self) -> str: | ||
"""Returns the refresh token URL (usually same as token URL).""" | ||
return self.get_token_url() |
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