Skip to content

validating auth context when using OIDC to publish #8525

@travi

Description

@travi

hi, folks 👋🏼

i maintain semantic-release and have been working toward adding official support for using the newly available trusted publishing. making the actual trusted publish work was straight forward enough, but i've been running into some roadblocks enabling it in the context of the rest of what semantic-release tries to enable as part of the release process.

the primary complication is a result of the fact that semantic-release interacts with several systems as part of the release process and cannot make the full release atomic. because of that, we do our best to precheck that the various steps are expected to be successful before taking steps that cannot be undone. for npm, we attempt to ensure the available token will be able to publish successfully.

before trusted publishing, we did our best to check this with npm whoami. this fell short of proving that a token had privileges to publish, but does confirm that the token is valid and not typo'd. with trusted publishing npm whoami isnt available (and wouldnt make as much logical sense as named anyway).

it was suggested to me that i could try to use dry-run with npm publish to accomplish similar, which sounded great. thankfully i found the shortcoming of this approach before fully moving forward with it. what wasn't clear to me on the surface was that dry-run was providing valuable feedback about the presence of a token or oidc context, but does not validate that the token is actually valid according to the registry. this comment appears to confirm that this is intentional behavior, which unfortunately leaves me in a tough spot for semantic-release. a dry-run publish without verifying that the token is a least valid is a degradation from the npm whoami check that we were doing previously. without this check, we increase the chances that our users will end up with partial releases that can be unrecoverable, forcing them to skip versions for what actually gets released all the way to the registry.

is there any other way for us to check the validity of a token before attempting to publish? if not today, is there any planned capability that might be coming soon?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions