Skip to content

Commit afe4fc8

Browse files
authored
Make sure runner-admin has both auth_url and auth_url_v2. (#4066)
1 parent a12731d commit afe4fc8

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Runner.Listener/Configuration/ConfigurationManager.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,21 @@ public async Task ConfigureAsync(CommandSettings command)
284284
{
285285
var runner = await _dotcomServer.ReplaceRunnerAsync(runnerSettings.PoolId, agent, runnerSettings.GitHubUrl, registerToken, publicKeyXML);
286286
runnerSettings.ServerUrlV2 = runner.RunnerAuthorization.ServerUrl;
287+
runnerSettings.UseV2Flow = true; // if we are using runner admin, we also need to hit broker
287288

288289
agent.Id = runner.Id;
289290
agent.Authorization = new TaskAgentAuthorization()
290291
{
291292
AuthorizationUrl = runner.RunnerAuthorization.AuthorizationUrl,
292293
ClientId = new Guid(runner.RunnerAuthorization.ClientId)
293294
};
295+
296+
if (!string.IsNullOrEmpty(runner.RunnerAuthorization.LegacyAuthorizationUrl?.AbsoluteUri))
297+
{
298+
agent.Authorization.AuthorizationUrl = runner.RunnerAuthorization.LegacyAuthorizationUrl;
299+
agent.Properties["EnableAuthMigrationByDefault"] = true;
300+
agent.Properties["AuthorizationUrlV2"] = runner.RunnerAuthorization.AuthorizationUrl.AbsoluteUri;
301+
}
294302
}
295303
else
296304
{
@@ -342,6 +350,13 @@ public async Task ConfigureAsync(CommandSettings command)
342350
AuthorizationUrl = runner.RunnerAuthorization.AuthorizationUrl,
343351
ClientId = new Guid(runner.RunnerAuthorization.ClientId)
344352
};
353+
354+
if (!string.IsNullOrEmpty(runner.RunnerAuthorization.LegacyAuthorizationUrl?.AbsoluteUri))
355+
{
356+
agent.Authorization.AuthorizationUrl = runner.RunnerAuthorization.LegacyAuthorizationUrl;
357+
agent.Properties["EnableAuthMigrationByDefault"] = true;
358+
agent.Properties["AuthorizationUrlV2"] = runner.RunnerAuthorization.AuthorizationUrl.AbsoluteUri;
359+
}
345360
}
346361
else
347362
{

src/Sdk/DTWebApi/WebApi/Runner.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ public Uri AuthorizationUrl
1818
internal set;
1919
}
2020

21+
/// <summary>
22+
/// The url to refresh tokens with legacy service
23+
/// </summary>
24+
[JsonProperty("legacy_authorization_url")]
25+
public Uri LegacyAuthorizationUrl
26+
{
27+
get;
28+
internal set;
29+
}
30+
2131
/// <summary>
2232
/// The url to connect to poll for messages
2333
/// </summary>

0 commit comments

Comments
 (0)