Skip to content

Add new pelican token create tool#2314

Merged
h2zh merged 11 commits into
PelicanPlatform:mainfrom
jhiemstrawisc:issue-2193
May 28, 2025
Merged

Add new pelican token create tool#2314
h2zh merged 11 commits into
PelicanPlatform:mainfrom
jhiemstrawisc:issue-2193

Conversation

@jhiemstrawisc

Copy link
Copy Markdown
Member

The most basic form of the command might look like:

pelican token create --read pelican://<fed>/<some path>

which will create a read token for the resource at the specified level (the object path trimmed of the namespace prefix).

For example, assuming I had the signing key for pelican://osg-htc.org/chtc/, I could create a token that grants read/write access to my entire section of staging with:

pelican token create --read --write pelican://osg-htc.org/chtc/staging/jhiemstra

Issuer determination happens by querying the Director and checking any locally-discovered (or provided) keys against the keys hosted by the director-discovered issuer URLs.

If the provided pelican URL can't be parsed or we fail to look up Director info for it, the user should still be able to bypass the errors by providing the needed information explicitly.

Note that the linked issue said failure to provide scopes should fall back to --read. I ultimately decided against this because I like the idea of forcing users to explicitly understand what capabilities their tokens contain. However, if the user provides no scopes, a warning is printed with a suggestion of which scopes are available.

Finally, this still allows for creation of totally arbitrary tokens as the old pelican origin token create utility did, even if the mechanism is a bit clunky. I'm okay with that for the time being, because I don't foresee anyone other than power users or developers wanting to use that (for now). After merging this, I'll open a followup issue to revisit it. For example, generation of a lot.delete token doesn't really need an input pelican URL, but for the time being the tool will still require some resource URL. The invocation might look like:

pelican token create --issuer https://bad-issuer.com --scope lot.delete pelican://some-path.com

this works because explicitly providing an issuer and a scope (the two values we'd otherwise seek to gain by querying the Director) lets us ignore the fact that there is no some-path.com federation.

@jhiemstrawisc jhiemstrawisc requested review from aowen-uwmad and h2zh May 14, 2025 20:54
@jhiemstrawisc jhiemstrawisc added enhancement New feature or request client Issue affecting the OSDF client security Facilitation A request from the RCF's labels May 14, 2025
@jhiemstrawisc jhiemstrawisc added this to the v7.17 milestone May 14, 2025
@jhiemstrawisc jhiemstrawisc linked an issue May 14, 2025 that may be closed by this pull request

@h2zh h2zh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is indeed a mega pull request, which not only contains the new command, but also ships an overhaul of the current token scope.

For the scopes with new names, would there be a backward compatibility issue? For example, when an old client creates a token with old scope name, could the new server recognize and verify it?

There are other smaller issues in the comments below.

Comment thread cache/self_monitor.go
Comment thread cmd/token.go Outdated
Comment thread cmd/origin_token.go
Comment thread cmd/token.go Outdated
Comment thread cmd/token.go Outdated
Comment thread cmd/token.go Outdated
Comment thread cmd/token.go Outdated
Comment thread cmd/token.go
Comment thread config/init_server_creds.go Outdated
Comment thread docs/scopes.yaml
We previously only had scopes for WLCG-style tokens. This adds Scitokens
scopes and hooks them up to the `.Path()` function so we can generate
a scope like `read:/foo` for scitokens and `storage.read:/foo` for WLCG.
WLCG and Scitokens encode their various scopes differently. For example,
a scitoken for reading `/foo` requires the `read:/foo` scope, while the
equivalent WLCG token requires the `storage.read:/foo` scope.

These new interfaces make it easier to parse some profile and then use
the `profile.ReadScope("/foo")` call to generate the correct scope.

@aowen-uwmad aowen-uwmad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One suggestion for the help text.
I'll let Howard decide when to approve the full PR.

Comment thread cmd/token.go Outdated

@h2zh h2zh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A security concern and other trivial comments

Comment thread cmd/token.go
Comment thread cmd/token.go Outdated
Comment thread cmd/token.go Outdated
Comment thread cmd/token.go Outdated
The function in question is one that checks whether a given issuer URL
provides a public key whose KID field matches that of a given private key.

I decided not to use "verify" in the name, because that word is loaded
and often connotes some kind of cryptographic operation. Instead, this
function only aims to make sure the user generating a token with the
new `pelican token create` function doesn't use an issuer that couldn't
possibly work.

@h2zh h2zh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀 LGTM

@h2zh h2zh merged commit 48498d7 into PelicanPlatform:main May 28, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Issue affecting the OSDF client enhancement New feature or request Facilitation A request from the RCF's security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pelican token create utility

3 participants