-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support configurable OIDC issuers (#62)
* Support configurable OIDC issuers Signed-off-by: Alex Cameron <[email protected]> * Update README help text Signed-off-by: Alex Cameron <[email protected]> * cli: use more descriptive metavars Signed-off-by: William Woodruff <[email protected]> * Stop binding the OIDC configuration to self Signed-off-by: Alex Cameron <[email protected]> * cli: fix merge Signed-off-by: William Woodruff <[email protected]> * cli, README: more `--help` descriptions Signed-off-by: William Woodruff <[email protected]> * cli, README: add `--help` text for `--ctfe` Signed-off-by: William Woodruff <[email protected]> * cli, sign, oidc: clarifying comments, relax issuer Use the `sub` claim for the proof of possession if we don't recognize the issuer's URL. Signed-off-by: William Woodruff <[email protected]> Co-authored-by: William Woodruff <[email protected]>
- Loading branch information
1 parent
2178a1c
commit 6117638
Showing
6 changed files
with
153 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright 2022 The Sigstore Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
""" | ||
Helper that queries the OpenID configuration for a given issuer and extracts its endpoints | ||
""" | ||
|
||
import urllib.parse | ||
|
||
import requests | ||
|
||
|
||
class IssuerError(Exception): | ||
pass | ||
|
||
|
||
class Issuer: | ||
def __init__(self, base_url: str) -> None: | ||
oidc_config_url = urllib.parse.urljoin( | ||
f"{base_url}/", ".well-known/openid-configuration" | ||
) | ||
|
||
resp: requests.Response = requests.get(oidc_config_url) | ||
try: | ||
resp.raise_for_status() | ||
except requests.HTTPError as http_error: | ||
raise IssuerError from http_error | ||
|
||
struct = resp.json() | ||
|
||
try: | ||
self.auth_endpoint: str = struct["authorization_endpoint"] | ||
except KeyError as key_error: | ||
raise IssuerError( | ||
f"OIDC configuration does not contain authorization endpoint: {struct}" | ||
) from key_error | ||
|
||
try: | ||
self.token_endpoint: str = struct["token_endpoint"] | ||
except KeyError as key_error: | ||
raise IssuerError( | ||
f"OIDC configuration does not contain token endpoint: {struct}" | ||
) from key_error |
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