Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] [OIDC 17] Add token API for trading bearer token for API key #10308

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

joelverhagen
Copy link
Member

@joelverhagen joelverhagen commented Dec 12, 2024

I will wait on merging this PR until more validation and review is done.

Progress on #10212.
Depends on #10306.

This adds a new token API for trading a bearer token for an API key.

A sample request is this:

POST /api/v2/token HTTP/1.1
Host: www.nuget.org
Authorization: Bearer {OIDC token}
Content-Type: application/json

{
    "token_type": "api_key",
    "username": "{username of the trust policy’s controlling user}"
}

A sample response is this:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "token_type": "api_key",
   "expires": "{ISO 8601 timestamp of expiration}",
   "api_key": "{short lived API key in clear text}"
}

The endpoint expects no other existing auth mechanism (no cookie auth, no API key auth) and will reject the request if present.

In the future, the full /api/v2/token URL will be discovered by the client via a new resource in the service index. For now, it will be hard coded in custom client scripts.

The {OIDC token} in the request message will be an Entra ID token for a service principal. In the future this can be more token types such as GitHub Actions OIDC tokens.

The username is the username of the trust policy’s controlling user, NOT the package owner scope. This aligns with the current API key design where API keys are only owned by users but can be scoped to either users or organizations. I am not confident on this decision but given this is a "closed beta" feature, we can try it and see how it goes, and change later with minimum disruption.

@joelverhagen joelverhagen changed the title [DRAFT] [OIDC] Add token API for trading bearer token for API key [DRAFT] [OIDC 16] Add token API for trading bearer token for API key Dec 12, 2024
@joelverhagen joelverhagen changed the title [DRAFT] [OIDC 16] Add token API for trading bearer token for API key [DRAFT] [OIDC 17] Add token API for trading bearer token for API key Dec 12, 2024
@joelverhagen joelverhagen changed the base branch from jver-oidc-ship-16 to dev January 10, 2025 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant