-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Improve missing/malformed file handling in user-jwts #42309
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
Conversation
@@ -123,7 +123,7 @@ public static void Register(ProjectCommandLineApplication app) | |||
var name = nameOption.HasValue() ? nameOption.Value() : Environment.UserName; | |||
optionsString += $"{Resources.JwtPrint_Name}: {name}{Environment.NewLine}"; | |||
|
|||
var audience = audienceOption.HasValue() ? audienceOption.Values : DevJwtCliHelpers.GetAudienceCandidatesFromLaunchSettings(project).ToList(); | |||
var audience = audienceOption.HasValue() ? audienceOption.Values : DevJwtCliHelpers.GetAudienceCandidatesFromLaunchSettings(project)?.ToList(); | |||
optionsString += audienceOption.HasValue() ? $"{Resources.JwtPrint_Audiences}: {audience}{Environment.NewLine}" : string.Empty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optionsString += audienceOption.HasValue() ? $"{Resources.JwtPrint_Audiences}: {audience}{Environment.NewLine}" : string.Empty; | |
optionsString += audience is not null ? $"{Resources.JwtPrint_Audiences}: {audience}{Environment.NewLine}" : string.Empty; |
This would then print the URL gotten from launchSettings which we weren't including before (bug creep 😆)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was actually intentional. This was meant to only display options that were explicitly passed by the user, not ones we implicitly derived (e.g. username from Environment.UserName
or urls from launchSettings).
So does the tool correctly discover all URLs from the launchSettings.json file now? The IIS Express URL? |
Yes, as of 9ff265e. |
} | ||
applicationUrls.AddRange(kestrelUrls); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: else if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's the right call here. We want to populate audience from both IIS and Kestrel-based URLs here so we get a complete set of audiences by the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I think it should be else if is because if the Kestrel check of profile.Value.TryGetProperty("commandName", out var commandName)
passes then the IIS check won't pass for this specific profile
. Again, it's a nit, not code we need to worry about performance for.
List<string> iisUrls = new(); | ||
if (iisExpress.TryGetProperty("applicationUrl", out var iisUrl)) | ||
{ | ||
iisUrls.Add(iisUrl.GetString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can these urls also be ;
separated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think so, but we'd need to check with VS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it out. VS will throw if you have something like this:
"iisExpress": {
"applicationUrl": "http://localhost:22686;http://localhost:22687",
"sslPort": 44333
}
Closes #42306
Closes #42304