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

JumpCloud provider improvements #799

Merged
merged 4 commits into from
Aug 17, 2023

Conversation

martincostello
Copy link
Member

  • Set the default domain for JumpCloud if a custom domain isn't used so that no extra configuration is required.
  • Enable PKCE for the JumpCloud provider by default.
  • Remove email and profile by default from JumpCloud.

I went with the second option on #797 (comment) - if it's not needed, then I can just mark the associated code as obsolete instead and delete it in the v8 branch.

/cc @AaronSadlerUK

Set the default domain for JumpCloud if a custom domain isn't used so that no extra configuration is required.
Enable PKCE for the JumpCloud provider by default.
Remove `email` and `profile` by default.
@kevinchalet
Copy link
Member

kevinchalet commented Aug 15, 2023

Looks good.

While you're at it, can you also update this helper? None of the calls to this method needs to set format arguments so it can be simplified.

private static string CreateUrl(string domain, string pathFormat, params object[] args)
{
var path = string.Format(CultureInfo.InvariantCulture, pathFormat, args);
// Enforce use of HTTPS
var builder = new UriBuilder(domain)
{
Path = path,
Port = -1,
Scheme = Uri.UriSchemeHttps,
};
return builder.Uri.ToString();
}

We should also mark the *Format fields as deprecated as these are not real format fields (there's no placeholder in any of the strings):

/// <summary>
/// Default path format to use for <see cref="OAuthOptions.AuthorizationEndpoint"/>.
/// </summary>
public static readonly string AuthorizationEndpointPathFormat = "/oauth2/auth";
/// <summary>
/// Default path format to use for <see cref="OAuthOptions.TokenEndpoint"/>.
/// </summary>
public static readonly string TokenEndpointPathFormat = "/oauth2/token";
/// <summary>
/// Default path format to use for <see cref="OAuthOptions.UserInformationEndpoint"/>.
/// </summary>
public static readonly string UserInformationEndpointPathFormat = "/userinfo";

Calls to string.Format should also be removed here:

/// <summary>
/// Default path to use for <see cref="OAuthOptions.AuthorizationEndpoint"/>.
/// </summary>
public static readonly string AuthorizationEndpointPath = string.Format(CultureInfo.InvariantCulture, AuthorizationEndpointPathFormat);
/// <summary>
/// Default path to use for <see cref="OAuthOptions.TokenEndpoint"/>.
/// </summary>
public static readonly string TokenEndpointPath = string.Format(CultureInfo.InvariantCulture, TokenEndpointPathFormat);
/// <summary>
/// Default path to use for <see cref="OAuthOptions.UserInformationEndpoint"/>.
/// </summary>
public static readonly string UserInformationEndpointPath = string.Format(CultureInfo.InvariantCulture, UserInformationEndpointPathFormat);

@martincostello
Copy link
Member Author

Probably not today, but at some point, I'm going to make a GitHub Actions workflow that leaves a comment on PRs that add new providers with a checklist of common things to check for (PKCE etc).

I'll also leave PRs at least a day so you get a chance to look at them 😅

I just get cagey with new providers when they seem ready after that time we had someone name-squat the package before we could actually publish it to NuGet.org...

@kevinchalet
Copy link
Member

Probably not today, but at some point, I'm going to make a GitHub Actions workflow that leaves a comment on PRs that add new providers with a checklist of common things to check for (PKCE etc).

Sounds like a great idea! Maybe we should also have a PR template that lists these things?

I'll also leave PRs at least a day so you get a chance to look at them 😅

My bad, I should have reacted earlier 🤣

I just get cagey with new providers when they seem ready after that time we had someone name-squat the package before we could actually publish it to NuGet.org...

Makes a lot of sense! To avoid that, I guess I should have chosen a more specific package prefix when starting this project (tho' prefix reservation was not a thing yet at the time 😅)

@martincostello
Copy link
Member Author

Sounds like a great idea! Maybe we should also have a PR template that lists these things?

I considered that, but there's already a template and people often ignore them and/or delete them I've found through experience.

I thought a comment @'d at the user post-open might be a bit more noticable. Plus we could potentially run a bit of code to differentiate between new providers and edits based on the diff to make it a bit smarter.

@kevinchalet
Copy link
Member

I thought we could have PR templates that would work the same way as issue templates (I.e with a screen showing the available templates) but apparently not: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository

So yeah, an automated message may make a lot of sense 😄

Remove redundant string formatting from JumpCloud.
@martincostello
Copy link
Member Author

@kevinchalet Happy with the latest changes?

@kevinchalet
Copy link
Member

Perfect, thanks! 👍🏻

@martincostello martincostello merged commit 163a006 into aspnet-contrib:dev Aug 17, 2023
8 checks passed
@martincostello martincostello deleted the jumpcloud-pcke branch August 17, 2023 16:06
@martincostello martincostello modified the milestones: 7.0.5, 8.0.0 Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants