Skip to content

Commit 893fadb

Browse files
Make JumpCloud domain optional
Set the default domain for JumpCloud if a custom domain isn't used so that no extra configuration is required.
1 parent 7cf71de commit 893fadb

File tree

6 files changed

+97
-10
lines changed

6 files changed

+97
-10
lines changed

AspNet.Security.OAuth.Providers.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{C2CA4B38-A
191191
docs\gitee.md = docs\gitee.md
192192
docs\github.md = docs\github.md
193193
docs\instagram.md = docs\instagram.md
194+
docs\jumpcloud.md = docs\jumpcloud.md
194195
docs\keycloak.md = docs\keycloak.md
195196
docs\kloudless.md = docs\kloudless.md
196197
docs\kook.md = docs\kook.md
@@ -296,7 +297,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Kook"
296297
EndProject
297298
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.PingOne", "src\AspNet.Security.OAuth.PingOne\AspNet.Security.OAuth.PingOne.csproj", "{CF8C4235-6AE6-404E-B572-4FF4E85AB5FF}"
298299
EndProject
299-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.Security.OAuth.JumpCloud", "src\AspNet.Security.OAuth.JumpCloud\AspNet.Security.OAuth.JumpCloud.csproj", "{8AF5DDBE-2631-4E71-9045-73A6356CE86B}"
300+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.JumpCloud", "src\AspNet.Security.OAuth.JumpCloud\AspNet.Security.OAuth.JumpCloud.csproj", "{8AF5DDBE-2631-4E71-9045-73A6356CE86B}"
300301
EndProject
301302
Global
302303
GlobalSection(SolutionConfigurationPlatforms) = preSolution

docs/jumpcloud.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ services.AddAuthentication(options => /* Auth configuration */)
88
{
99
options.ClientId = "my-client-id";
1010
options.ClientSecret = "my-client-secret";
11-
options.Domain = "https://oauth.id.jumpcloud.com";
11+
options.Domain = "oauth.id.jumpcloud.com";
1212
});
1313
```
1414

1515
## Required Additional Settings
1616

17-
| Property Name | Property Type | Description | Default Value |
18-
|:--|:--|:--|:--|
19-
| `Domain` | `string?` | The JumpCloud domain to use for authentication. | `null` |
17+
_None._
2018

2119
## Optional Settings
2220

23-
_None._
21+
| Property Name | Property Type | Description | Default Value |
22+
|:--|:--|:--|:--|
23+
| `Domain` | `string?` | The JumpCloud domain to use for authentication. | `"oauth.id.jumpcloud.com"` |

src/AspNet.Security.OAuth.JumpCloud/JumpCloudAuthenticationOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public JumpCloudAuthenticationOptions()
3333
}
3434

3535
/// <summary>
36-
/// Gets or sets the JumpCloud domain (Org URL) to use for authentication.
36+
/// Gets or sets the optional JumpCloud domain (Org URL) to use for authentication.
3737
/// </summary>
38-
public string? Domain { get; set; }
38+
public string? Domain { get; set; } = "oauth.id.jumpcloud.com";
3939

4040
/// <inheritdoc/>
4141
public override void Validate()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
4+
* for more information concerning the license and the contributors participating to this project.
5+
*/
6+
7+
namespace AspNet.Security.OAuth.JumpCloud;
8+
9+
public class JumpCloudEnterpriseTests : OAuthTests<JumpCloudAuthenticationOptions>
10+
{
11+
public JumpCloudEnterpriseTests(ITestOutputHelper outputHelper)
12+
{
13+
OutputHelper = outputHelper;
14+
}
15+
16+
public override string DefaultScheme => JumpCloudAuthenticationDefaults.AuthenticationScheme;
17+
18+
protected override string BundleName => "JumpCloud";
19+
20+
protected internal override void RegisterAuthentication(AuthenticationBuilder builder)
21+
{
22+
builder.AddJumpCloud(options =>
23+
{
24+
ConfigureDefaults(builder, options);
25+
options.Domain = "jumpcloud.local";
26+
});
27+
}
28+
29+
[Theory]
30+
[InlineData(ClaimTypes.Email, "[email protected]")]
31+
[InlineData(ClaimTypes.GivenName, "John")]
32+
[InlineData(ClaimTypes.Name, "John Doe")]
33+
[InlineData(ClaimTypes.NameIdentifier, "00uid4BxXw6I6TV4m0g3")]
34+
[InlineData(ClaimTypes.Surname, "Doe")]
35+
public async Task Can_Sign_In_Using_JumpCloud(string claimType, string claimValue)
36+
{
37+
// Arrange
38+
using var server = CreateTestServer();
39+
40+
// Act
41+
var claims = await AuthenticateUserAsync(server);
42+
43+
// Assert
44+
AssertClaim(claims, claimType, claimValue);
45+
}
46+
}

test/AspNet.Security.OAuth.Providers.Tests/JumpCloud/JumpCloudTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ protected internal override void RegisterAuthentication(AuthenticationBuilder bu
2020
builder.AddJumpCloud(options =>
2121
{
2222
ConfigureDefaults(builder, options);
23-
options.Domain = "jumpcloud.local";
2423
});
2524
}
2625

test/AspNet.Security.OAuth.Providers.Tests/JumpCloud/bundle.json

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,47 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
2+
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/main/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
33
"items": [
4+
{
5+
"comment": "https://jumpcloud.com/support/sso-with-oidc",
6+
"uri": "https://oauth.id.jumpcloud.com/oauth2/token",
7+
"method": "POST",
8+
"contentFormat": "json",
9+
"contentJson": {
10+
"access_token": "secret-access-token",
11+
"token_type": "Bearer",
12+
"expires_in": 3600,
13+
"scope": "openid email",
14+
"refresh_token": "secret-refresh-token",
15+
"id_token": "secret-id-token"
16+
}
17+
},
18+
{
19+
"comment": "https://jumpcloud.com/support/sso-with-oidc",
20+
"uri": "https://oauth.id.jumpcloud.com/userinfo",
21+
"contentFormat": "json",
22+
"contentJson": {
23+
"sub": "00uid4BxXw6I6TV4m0g3",
24+
"name": "John Doe",
25+
"nickname": "Jimmy",
26+
"given_name": "John",
27+
"middle_name": "James",
28+
"family_name": "Doe",
29+
"profile": "https://example.com/john.doe",
30+
"zoneinfo": "America/Los_Angeles",
31+
"locale": "en-US",
32+
"updated_at": 1311280970,
33+
"email": "[email protected]",
34+
"email_verified": true,
35+
"address": {
36+
"street_address": "123 Hollywood Blvd.",
37+
"locality": "Los Angeles",
38+
"region": "CA",
39+
"postal_code": "90210",
40+
"country": "US"
41+
},
42+
"phone_number": "+1 (425) 555-1212"
43+
}
44+
},
445
{
546
"comment": "https://jumpcloud.com/support/sso-with-oidc",
647
"uri": "https://jumpcloud.local/oauth2/token",

0 commit comments

Comments
 (0)