Skip to content

Conversation

@patrickbrophy
Copy link
Contributor

Fixes #2812 - Token discovery was incorrectly rejecting valid SciTokens and logging empty token location. The cause of this was that token validation only checked for WLCG tokens, causing valid SciTokens to be incorrectly flagged as unacceptable.

- Fixed bug in tests
- Added token location tracking
- Refactored token accebility policy
@patrickbrophy patrickbrophy added this to the v7.23 milestone Dec 8, 2025
@patrickbrophy patrickbrophy added bug Something isn't working client Issue affecting the OSDF client labels Dec 8, 2025
Copy link
Collaborator

@turetske turetske left a comment

Choose a reason for hiding this comment

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

This looks mostly good, but I would like to see some explicit unit tests for the helper functions. I'd also like to see some Wlcg token testing (because you switched out wlcg for scitoken, and I think we should have both)


// matchesResource checks if the target resource matches the scope resource.
// For shared URLs, exact matches are preferred, but prefix matching is also acceptable.
func matchesResource(targetResource, scopeResource string, operation config.TokenOperation) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to have unit tests for these helper functions. Helps identify more specifically when/if we introduce bugs that cause token verification issues.

}

// Verify if a scitoken‐profile JWT is acceptable for a given namespace
func TestTokenIsAcceptableForSciTokens(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at this because you altered the test. This really feels like it should be in acquire_token_test.go file rather than main.

strings.HasPrefix(targetNorm, scopeNorm)
}

func isValidWLCGScope(authz string, operation config.TokenOperation) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above comment

}
}

func isValidSciScope(authz string, operation config.TokenOperation) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above comment

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

Labels

bug Something isn't working client Issue affecting the OSDF client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange behavior from token discovery code

2 participants