Skip to content

Conversation

TingluoHuang
Copy link
Member

@TingluoHuang TingluoHuang commented Mar 31, 2025

Here is the normally flow we auth with service today:

  • Load .credentials file to create a VssCredential object
  • Use the created VssCredential to ConnectAsync for different server, ex: RunnerServer, BrokerServer, RunServer, ActionsRunServer, etc.

The service will send down a newer version of the .credentials config that looks like the following:

{
  "scheme": "OAuth",
  "data": {
    "clientId": "GUID",
    "authorizationUrl": "https://tokenghub.actions.githubusercontent.com/_apis/oauth2/token/GUID",
    "authorizationUrlV2": "https://runner-auth.actions.githubusercontent.com/",
    "requireFipsCryptography": "True"
  }
}

I am changing the runner.listener to realize there might be 2 types of VssCredential, one created with authorizationUrl, another created with authorizationUrlV2.

Different VssCredential will be used for ConnectAsync for different server.

  • RunnerServer: authorizationUrl
  • ActionsRUnServer: authorizationUrl
  • BorkerServer: authorizationUrlV2
  • RunServer: authorizationUrlV2

This PR is not making real change of using authorizationUrlV2, since we pass allowAuthUrlV2: false in all the places we create VssCredential via VssCredentials GetVssCredentials(IHostContext context, bool allowAuthUrlV2);

https://github.com/github/actions-runner-admin/issues/1656

@TingluoHuang TingluoHuang requested a review from a team as a code owner March 31, 2025 18:45
Base automatically changed from users/tihuang/hostcontext to main March 31, 2025 19:26
@TingluoHuang TingluoHuang force-pushed the users/tihuang/loadcred branch 2 times, most recently from e74b6fa to 4af9b2c Compare March 31, 2025 20:04
{
credData = migratedCred;

// Re-write .credentials with Token URL
Copy link
Member Author

Choose a reason for hiding this comment

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

remove the code left when we finish SPS->Token migration.
We still want to keep .credentials and .credentials_migrated for a while in this case.

@@ -51,21 +51,16 @@ public VssCredentials LoadCredentials()

CredentialData credData = store.GetCredentials();
var migratedCred = store.GetMigratedCredentials();
if (migratedCred != null)
if (migratedCred != null &&
migratedCred.Scheme == Constants.Configuration.OAuth)
Copy link
Member Author

Choose a reason for hiding this comment

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

Hosted runner will have different auth schema.

@@ -197,6 +197,16 @@ private async Task UpdateRunnerCredentialsAsync(string serviceType, string confi
await ReportTelemetryAsync($"Credential clientId in refreshed config '{refreshedClientId ?? "Empty"}' does not match the current credential clientId '{clientId}'.");
return;
}

// make sure the credential authorizationUrl in the refreshed config match the current credential authorizationUrl for OAuth auth scheme
var authorizationUrl = _credData.Data.GetValueOrDefault("authorizationUrl", null);
Copy link
Member Author

Choose a reason for hiding this comment

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

this will make sure the .credentials_migrated is identical with .credentials for us to safely fallback.

@TingluoHuang TingluoHuang force-pushed the users/tihuang/loadcred branch from 4af9b2c to 231f9e1 Compare March 31, 2025 20:32
@TingluoHuang TingluoHuang merged commit d470139 into main Mar 31, 2025
9 checks passed
@TingluoHuang TingluoHuang deleted the users/tihuang/loadcred branch March 31, 2025 21:05
marko-k0 pushed a commit to dfinity/runner that referenced this pull request May 13, 2025
sirredbeard pushed a commit to sirredbeard/runner that referenced this pull request Jun 11, 2025
sirredbeard pushed a commit to sirredbeard/runner that referenced this pull request Jun 11, 2025
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.

2 participants