Skip to content

Add support for token auth using tokens fetched from arbitrary external tools - #74

Open
cnweaver wants to merge 5 commits into
masterfrom
external-token-support
Open

Add support for token auth using tokens fetched from arbitrary external tools#74
cnweaver wants to merge 5 commits into
masterfrom
external-token-support

Conversation

@cnweaver

Copy link
Copy Markdown
Collaborator

This enables using token auth with non-OIDC token issuing system systems, such as LIGO's vault/openbao-based system.

…al tools.

Perform slightly more careful parsing of URLs.
@cnweaver cnweaver self-assigned this Aug 12, 2026
@cnweaver cnweaver added the enhancement New feature or request label Aug 12, 2026

@jnation3406 jnation3406 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I don't understand what its doing, but this seems like something internal for you so you know the required format of the params and token_command without documentation.

Comment thread adc/auth.py
if len(sections) != 3:
raise RuntimeError("Token callback output does not appear to be a valid JWT")
try:
# The JWT spec mandates that base 64 padding be omitted, but

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this would be handled automatically with a jwt library, like pyjwt. Maybe you don't want to include extra libraries though.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, yes (with this it looks like); I figured that a new dependency was a lot of overhead for something that requires such minimal parsing, since we aren't concerned with any of the cryptographic verification.

Comment thread adc/auth.py
sections[1] += b"=="
elif m == 3:
sections[1] += b"="
elif m == 1:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you not need an else for the case of m == 0 potentially?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If m==0 the amount of padding needed is zero by definition.

Comment thread adc/auth.py Outdated
exp_value = claims["exp"]
if not isinstance(exp_value, int) and not isinstance(exp_value, float):
raise RuntimeError("Token expiration value is not a number")
if isinstance(exp_value, int):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its safe to set exp_value = float(exp_value) without checking if its int.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec requires it to be a number, so I figured I might as well implement that check to flag invalid inputs. Otherwise, a malformed token could cause a ValueError from float(), which would require a similar amount of error handling.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm talking about removing line 137, not line 135-6

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, yes, that check is redundant to what float() already does internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants