Skip to content

Commit 75ebd13

Browse files
authored
Add SuperOffice provider
1 parent 5484c55 commit 75ebd13

15 files changed

+1091
-1
lines changed

AspNet.Security.OAuth.Providers.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{C2CA4B38-A
188188
EndProject
189189
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Basecamp", "src\AspNet.Security.OAuth.Basecamp\AspNet.Security.OAuth.Basecamp.csproj", "{42306484-B2BF-4B52-B950-E0CDFA58B02A}"
190190
EndProject
191+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.SuperOffice", "src\AspNet.Security.OAuth.SuperOffice\AspNet.Security.OAuth.SuperOffice.csproj", "{286D1FB0-716C-47CB-A519-22E1D34DFDF7}"
192+
EndProject
191193
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Okta", "src\AspNet.Security.OAuth.Okta\AspNet.Security.OAuth.Okta.csproj", "{F8A4A5C4-86D9-4CF2-A2FC-3B46CCC51750}"
192194
EndProject
193195
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{B1792D2A-6D6C-4484-968E-D68DF376BA40}"
@@ -453,6 +455,10 @@ Global
453455
{42306484-B2BF-4B52-B950-E0CDFA58B02A}.Debug|Any CPU.Build.0 = Debug|Any CPU
454456
{42306484-B2BF-4B52-B950-E0CDFA58B02A}.Release|Any CPU.ActiveCfg = Release|Any CPU
455457
{42306484-B2BF-4B52-B950-E0CDFA58B02A}.Release|Any CPU.Build.0 = Release|Any CPU
458+
{286D1FB0-716C-47CB-A519-22E1D34DFDF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
459+
{286D1FB0-716C-47CB-A519-22E1D34DFDF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
460+
{286D1FB0-716C-47CB-A519-22E1D34DFDF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
461+
{286D1FB0-716C-47CB-A519-22E1D34DFDF7}.Release|Any CPU.Build.0 = Release|Any CPU
456462
{F8A4A5C4-86D9-4CF2-A2FC-3B46CCC51750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
457463
{F8A4A5C4-86D9-4CF2-A2FC-3B46CCC51750}.Debug|Any CPU.Build.0 = Debug|Any CPU
458464
{F8A4A5C4-86D9-4CF2-A2FC-3B46CCC51750}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -530,6 +536,7 @@ Global
530536
{E82424B3-0E73-4954-B6A6-BFF1029A08DE} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
531537
{C2CA4B38-AA21-4CA4-8799-2E8C8C06754F} = {E9DAB098-A902-4EF5-9AEE-CF735DF31E35}
532538
{42306484-B2BF-4B52-B950-E0CDFA58B02A} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
539+
{286D1FB0-716C-47CB-A519-22E1D34DFDF7} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
533540
{F8A4A5C4-86D9-4CF2-A2FC-3B46CCC51750} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
534541
{B1792D2A-6D6C-4484-968E-D68DF376BA40} = {3FA3F7B5-5373-4E43-8F45-8EC18249E526}
535542
EndGlobalSection

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.5" />
1010
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="3.1.5" />
1111
<PackageVersion Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0" />
12+
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="5.5.0" />
1213
<PackageVersion Include="Microsoft.NetCore.Analyzers" Version="3.0.0" />
1314
<PackageVersion Include="Moq" Version="4.14.5" />
1415
<PackageVersion Include="Shouldly" Version="3.0.2" />

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ If a provider you're looking for does not exist, consider making a PR to add one
155155
| Spotify | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Spotify?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Spotify/ "Download AspNet.Security.OAuth.Spotify from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Spotify?includePreReleases=false)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Spotify "Download AspNet.Security.OAuth.Spotify from MyGet.org") | [Documentation](https://developer.spotify.com/documentation/general/guides/authorization-guide/ "Spotify developer documentation") |
156156
| Stack Exchange | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.StackExchange?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.StackExchange/ "Download AspNet.Security.OAuth.StackExchange from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.StackExchange?includePreReleases=false)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.StackExchange "Download AspNet.Security.OAuth.StackExchange from MyGet.org") | [Documentation](https://api.stackexchange.com/docs/authentication "Stack Exchange developer documentation") |
157157
| Strava | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Strava?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Strava/ "Download AspNet.Security.OAuth.Strava from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Strava?includePreReleases=false)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Strava "Download AspNet.Security.OAuth.Strava from MyGet.org") | [Documentation](https://developers.strava.com/docs/authentication/ "Strava developer documentation") |
158+
| SuperOffice | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.SuperOffice?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.SuperOffice/ "Download AspNet.Security.OAuth.SuperOffice from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.SuperOffice?includePreReleases=false)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.SuperOffice "Download AspNet.Security.OAuth.SuperOffice from MyGet.org") | [Documentation](https://community.superoffice.com/en/developer/create-apps/concepts/authentication/ "SuperOffice developer documentation") |
158159
| Trakt | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Trakt?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Trakt/ "Download AspNet.Security.OAuth.Trakt from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Trakt?includePreReleases=false)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Trakt "Download AspNet.Security.OAuth.Trakt from MyGet.org") | [Documentation](https://trakt.docs.apiary.io/ "Trakt developer documentation") |
159160
| Twitch | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Twitch?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Twitch/ "Download AspNet.Security.OAuth.Twitch from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Twitch?includePreReleases=false)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Twitch "Download AspNet.Security.OAuth.Twitch from MyGet.org") | [Documentation](https://dev.twitch.tv/docs/authentication/ "Twitch developer documentation") |
160161
| Untappd | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Untappd?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Untappd/ "Download AspNet.Security.OAuth.Untappd from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Untappd?includePreReleases=false)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Untappd "Download AspNet.Security.OAuth.Untappd from MyGet.org") | [Documentation](https://untappd.com/api/docs#authentication "Untappd developer documentation") |
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
5+
</PropertyGroup>
6+
7+
<PropertyGroup>
8+
<Description>ASP.NET Core security middleware enabling SuperOffice authentication.</Description>
9+
<Authors>Anthony Yates</Authors>
10+
<PackageTags>superoffice;aspnetcore;authentication;oauth;security</PackageTags>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
15+
<PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
16+
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" />
17+
</ItemGroup>
18+
19+
</Project>
Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
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+
using Microsoft.AspNetCore.Authentication;
7+
8+
namespace AspNet.Security.OAuth.SuperOffice
9+
{
10+
/// <summary>
11+
/// Contains constants specific to the <see cref="SuperOfficeAuthenticationHandler"/>.
12+
/// </summary>
13+
public static class SuperOfficeAuthenticationConstants
14+
{
15+
public static class ClaimNames
16+
{
17+
/// <summary>
18+
/// Tenant's user identity.
19+
/// </summary>
20+
public const string AssociateId = "http://schemes.superoffice.net/identity/associateid";
21+
22+
/// <summary>
23+
/// Current user's company name.
24+
/// </summary>
25+
public const string CompanyName = "http://schemes.superoffice.net/identity/company_name";
26+
27+
/// <summary>
28+
/// Current user tenant identifier.
29+
/// </summary>
30+
public const string ContextIdentifier = "http://schemes.superoffice.net/identity/ctx";
31+
32+
/// <summary>
33+
/// Current SuperId user email address.
34+
/// </summary>
35+
public const string Email = "http://schemes.superoffice.net/identity/email";
36+
37+
/// <summary>
38+
/// Current user first name.
39+
/// </summary>
40+
public const string FirstName = "http://schemes.superoffice.net/identity/firstname";
41+
42+
/// <summary>
43+
/// SuperOffice identity provider name.
44+
/// </summary>
45+
public const string IdentityProvider = "http://schemes.superoffice.net/identity/identityprovider";
46+
47+
/// <summary>
48+
/// Current user initials.
49+
/// </summary>
50+
public const string Initials = "http://schemes.superoffice.net/identity/initials";
51+
52+
/// <summary>
53+
/// Determines if current user is an administrator.
54+
/// </summary>
55+
public const string IsAdministrator = "http://schemes.superoffice.net/identity/is_administrator";
56+
57+
/// <summary>
58+
/// Current user last name.
59+
/// </summary>
60+
public const string LastName = "http://schemes.superoffice.net/identity/lastname";
61+
62+
/// <summary>
63+
/// Endpoint of SuperOffice SOAP web services.
64+
/// </summary>
65+
public const string NetServerUrl = "http://schemes.superoffice.net/identity/netserver_url";
66+
67+
/// <summary>
68+
/// Tenant database serial number.
69+
/// </summary>
70+
public const string Serial = "http://schemes.superoffice.net/identity/serial";
71+
72+
/// <summary>
73+
/// Current user's tenant primary email address.
74+
/// </summary>
75+
public const string PrimaryEmail = "http://schemes.superoffice.net/identity/so_primary_email_address";
76+
77+
/// <summary>
78+
/// Identifier used to exchange for a system user ticket.
79+
/// </summary>
80+
public const string SystemToken = "http://schemes.superoffice.net/identity/system_token";
81+
82+
/// <summary>
83+
/// Credentials token used to access web services.
84+
/// </summary>
85+
public const string Ticket = "http://schemes.superoffice.net/identity/ticket";
86+
87+
/// <summary>
88+
/// Current user's username.
89+
/// </summary>
90+
public const string UserPrincipalName = "http://schemes.superoffice.net/identity/upn";
91+
92+
/// <summary>
93+
/// Endpoint of SuperOffice REST web services.
94+
/// </summary>
95+
public const string WebApiUrl = "http://schemes.superoffice.net/identity/webapi_url";
96+
}
97+
98+
internal static class FormatStrings
99+
{
100+
/// <summary>
101+
/// A format string used to construct <see cref="SuperOfficeAuthenticationOptions.Authority"/>.
102+
/// </summary>
103+
public const string Authority = "https://{0}.superoffice.com/login";
104+
105+
/// <summary>
106+
/// A format string used to populate OAuth authorize endpoint.
107+
/// </summary>
108+
public const string AuthorizeEndpoint = "https://{0}.superoffice.com/login/common/oauth/authorize";
109+
110+
/// <summary>
111+
/// A format string used to construct <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>.
112+
/// </summary>
113+
public const string ClaimsIssuer = "https://{0}.superoffice.com";
114+
115+
/// <summary>
116+
/// A format string used to construct well-known configuration endpoint.
117+
/// </summary>
118+
public const string MetadataEndpoint = "https://{0}.superoffice.com/login/.well-known/openid-configuration";
119+
120+
/// <summary>
121+
/// A format string used to populate OAuth token endpoint.
122+
/// </summary>
123+
public const string TokenEndpoint = "https://{0}.superoffice.com/login/common/oauth/tokens";
124+
125+
/// <summary>
126+
/// A format string used to obtain user claims.
127+
/// </summary>
128+
/// <remarks>The final user information URL contains the protocol, host and tenant.</remarks>
129+
/// <example>https://sod.superoffice.com/Cust12345/api/v1/user/currentPrincipal</example>
130+
public const string UserInfoEndpoint = "/{0}/api/v1/user/currentPrincipal";
131+
}
132+
133+
public static class PrincipalNames
134+
{
135+
/// <summary>
136+
/// Associate name (e.g. logon name) for the current user.
137+
/// </summary>
138+
public const string Associate = "Associate";
139+
140+
/// <summary>
141+
/// Associate ID for the current user.
142+
/// </summary>
143+
public const string AssociateId = "AssociateId";
144+
145+
/// <summary>
146+
/// Business ID for the company that the user belongs to.
147+
/// </summary>
148+
public const string BusinessId = "BusinessId";
149+
150+
/// <summary>
151+
/// Category ID of the company that the user belongs to.
152+
/// </summary>
153+
public const string CategoryId = "CategoryId";
154+
155+
/// <summary>
156+
/// Company of the associate's person.
157+
/// </summary>
158+
public const string ContactId = "ContactId";
159+
160+
/// <summary>
161+
/// Owner (AssociateId) of the company that the user belongs to.
162+
/// </summary>
163+
public const string ContactOwner = "ContactOwner";
164+
165+
/// <summary>
166+
/// Name of the tenant context identifier.
167+
/// </summary>
168+
public const string ContextIdentifier = "ContextIdentifier";
169+
170+
/// <summary>
171+
/// Country ID for the user.
172+
/// </summary>
173+
public const string CountryId = "CountryId";
174+
175+
/// <summary>
176+
/// Name of the database context.
177+
/// </summary>
178+
public const string DatabaseContextIdentifier = "DatabaseContextIdentifier";
179+
180+
/// <summary>
181+
/// Service user access level.
182+
/// </summary>
183+
public const string EjAccessLevel = "EjAccessLevel";
184+
185+
/// <summary>
186+
/// Primary key in Service user table.
187+
/// </summary>
188+
public const string EjUserId = "EjUserId";
189+
190+
/// <summary>
191+
/// Service user status.
192+
/// </summary>
193+
public const string EjUserStatus = "EjUserStatus";
194+
195+
/// <summary>
196+
/// The Person e-mail address if the associate is a person. Use IsPerson to check.
197+
/// </summary>
198+
public const string EmailAddress = "EMailAddress";
199+
200+
/// <summary>
201+
/// The Person full name if the associate is a person. Use IsPerson to check.
202+
/// </summary>
203+
public const string FullName = "FullName";
204+
205+
/// <summary>
206+
/// Functional rights for the user. This array is sorted.
207+
/// </summary>
208+
public const string FunctionRights = "FunctionRights";
209+
210+
/// <summary>
211+
/// Associate's group ID.
212+
/// </summary>
213+
public const string GroupId = "GroupId";
214+
215+
/// <summary>
216+
/// Country ID for the user's home country. This is the default country ID when creating new items.
217+
/// </summary>
218+
public const string HomeCountryId = "HomeCountryId";
219+
220+
/// <summary>
221+
/// Is this associate a person, and not a resource?
222+
/// </summary>
223+
public const string IsPerson = "IsPerson";
224+
225+
/// <summary>
226+
/// Licenses granted to the site and user.
227+
/// </summary>
228+
public const string Licenses = "Licenses";
229+
230+
/// <summary>
231+
/// Associate's person ID.
232+
/// </summary>
233+
public const string PersonId = "PersonId";
234+
235+
/// <summary>
236+
/// The credentials used for authenticating this user.
237+
/// </summary>
238+
public const string ProvidedCredentials = "ProvidedCredentials";
239+
240+
/// <summary>
241+
/// Description (e.g. tooltip) for the user's role.
242+
/// </summary>
243+
public const string RoleDescription = "RoleDescription";
244+
245+
/// <summary>
246+
/// ID of the user's role.
247+
/// </summary>
248+
public const string RoleId = "RoleId";
249+
250+
/// <summary>
251+
/// Name of the user's role.
252+
/// </summary>
253+
public const string RoleName = "RoleName";
254+
255+
/// <summary>
256+
/// Type of user.
257+
/// </summary>
258+
public const string RoleType = "RoleType";
259+
260+
/// <summary>
261+
/// Secondary user groups.
262+
/// </summary>
263+
public const string SecondaryGroups = "SecondaryGroups";
264+
265+
/// <summary>
266+
/// Type of user.
267+
/// </summary>
268+
public const string UserType = "UserType";
269+
}
270+
}
271+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
using Microsoft.AspNetCore.Authentication;
8+
9+
namespace AspNet.Security.OAuth.SuperOffice
10+
{
11+
/// <summary>
12+
/// Default values used by the SuperOffice authentication middleware.
13+
/// </summary>
14+
public static class SuperOfficeAuthenticationDefaults
15+
{
16+
/// <summary>
17+
/// Default value for <see cref="AuthenticationScheme.Name"/>.
18+
/// </summary>
19+
public const string AuthenticationScheme = "SuperOffice";
20+
21+
/// <summary>
22+
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>.
23+
/// </summary>
24+
public const string CallbackPath = "/signin-superoffice";
25+
26+
/// <summary>
27+
/// Default value for <see cref="AuthenticationScheme.DisplayName"/>.
28+
/// </summary>
29+
public static readonly string DisplayName = "SuperOffice";
30+
}
31+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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.SuperOffice
8+
{
9+
/// <summary>
10+
/// Used to map usage to specific online environment, i.e. development, stage or production.
11+
/// </summary>
12+
public enum SuperOfficeAuthenticationEnvironment
13+
{
14+
Development,
15+
Stage,
16+
Production
17+
}
18+
}

0 commit comments

Comments
 (0)