Skip to content

Commit 99363bc

Browse files
Carl/sdk integration work button up (#3)
* WIP * enhance version command * skip user prompts with a CLI options. * docs * JWT util command * linting * add discovery to the command line util * hide unimplemented commands
1 parent 2fd7b0a commit 99363bc

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed

src/planet_auth/auth_client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,26 @@ def userinfo_from_access_token(self, access_token: str) -> dict:
450450
message="User information lookup is not implemented for the current authentication mechanism"
451451
)
452452

453+
def oidc_discovery(self) -> dict:
454+
"""
455+
Query the authorization server's OIDC discovery endpoint for server information.
456+
Returns:
457+
Returns the OIDC discovery dictionary.
458+
"""
459+
raise AuthClientException(
460+
message="OIDC discovery is not implemented for the current authentication mechanism."
461+
)
462+
463+
# def oauth_discovery(self) -> dict:
464+
# """
465+
# Query the authorization server's OAuth2 discovery endpoint for server information.
466+
# Returns:
467+
# Returns the OAuth2 discovery dictionary.
468+
# """
469+
# raise AuthClientException(
470+
# message="OAuth2 discovery is not implemented for the current authentication mechanism."
471+
# )
472+
453473
def get_scopes(self) -> List[str]:
454474
"""
455475
Query the authorization server for a list of scopes.

src/planet_auth/oidc/auth_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,14 @@ def userinfo_from_access_token(self, access_token: str) -> dict:
588588
"""
589589
return self.userinfo_client().userinfo_from_access_token(access_token=access_token)
590590

591+
def oidc_discovery(self) -> dict:
592+
"""
593+
Query the authorization server's OIDC discovery endpoint for server information.
594+
Returns:
595+
Returns the OIDC discovery dictionary.
596+
"""
597+
return self._discovery()
598+
591599
def get_scopes(self) -> List[str]:
592600
"""
593601
Query the authorization server for a list of scopes.

src/planet_auth_utils/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
cmd_oauth_revoke_access_token,
4040
cmd_oauth_revoke_refresh_token,
4141
cmd_oauth_userinfo,
42+
cmd_oauth_discovery,
4243
cmd_oauth_list_scopes,
4344
cmd_oauth_print_access_token,
4445
)
@@ -103,6 +104,7 @@
103104
"cmd_oauth_revoke_access_token",
104105
"cmd_oauth_revoke_refresh_token",
105106
"cmd_oauth_userinfo",
107+
"cmd_oauth_discovery",
106108
"cmd_oauth_list_scopes",
107109
"cmd_oauth_print_access_token",
108110
"cmd_pllegacy",

src/planet_auth_utils/commands/cli/jwt_cmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def cmd_jwt_validate_oauth(ctx, token, token_file, audience, issuer, human_reada
225225
)
226226

227227

228-
@cmd_jwt.command("validate-rs256")
228+
@cmd_jwt.command("validate-rs256", hidden=True)
229229
@click.pass_context
230230
@opt_human_readable
231231
@opt_token
@@ -239,7 +239,7 @@ def cmd_jwt_validate_rs256(ctx, token, token_file, human_readable):
239239
raise NotImplementedError("Command not implemented")
240240

241241

242-
@cmd_jwt.command("validate-hs512")
242+
@cmd_jwt.command("validate-hs512", hidden=True)
243243
@click.pass_context
244244
@opt_human_readable
245245
@opt_token

src/planet_auth_utils/commands/cli/oauth_cmd.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ def cmd_oauth_list_scopes(ctx):
163163
print_obj([])
164164

165165

166+
@cmd_oauth.command("discovery")
167+
@click.pass_context
168+
@recast_exceptions_to_click(AuthException, FileNotFoundError)
169+
def cmd_oauth_discovery(ctx):
170+
"""
171+
Look up OAuth server discovery information.
172+
"""
173+
auth_client = ctx.obj["AUTH"].auth_client()
174+
discovery_json = auth_client.oidc_discovery()
175+
print_obj(discovery_json)
176+
177+
166178
@cmd_oauth.command("validate-access-token")
167179
@click.pass_context
168180
@opt_human_readable

0 commit comments

Comments
 (0)