Skip to content

Commit

Permalink
Add SuperOffice provider
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyYates authored Jul 7, 2020
1 parent 5484c55 commit 75ebd13
Show file tree
Hide file tree
Showing 15 changed files with 1,091 additions and 1 deletion.
7 changes: 7 additions & 0 deletions AspNet.Security.OAuth.Providers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{C2CA4B38-A
EndProject
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}"
EndProject
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}"
EndProject
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}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{B1792D2A-6D6C-4484-968E-D68DF376BA40}"
Expand Down Expand Up @@ -453,6 +455,10 @@ Global
{42306484-B2BF-4B52-B950-E0CDFA58B02A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42306484-B2BF-4B52-B950-E0CDFA58B02A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42306484-B2BF-4B52-B950-E0CDFA58B02A}.Release|Any CPU.Build.0 = Release|Any CPU
{286D1FB0-716C-47CB-A519-22E1D34DFDF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{286D1FB0-716C-47CB-A519-22E1D34DFDF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{286D1FB0-716C-47CB-A519-22E1D34DFDF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{286D1FB0-716C-47CB-A519-22E1D34DFDF7}.Release|Any CPU.Build.0 = Release|Any CPU
{F8A4A5C4-86D9-4CF2-A2FC-3B46CCC51750}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8A4A5C4-86D9-4CF2-A2FC-3B46CCC51750}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8A4A5C4-86D9-4CF2-A2FC-3B46CCC51750}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -530,6 +536,7 @@ Global
{E82424B3-0E73-4954-B6A6-BFF1029A08DE} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{C2CA4B38-AA21-4CA4-8799-2E8C8C06754F} = {E9DAB098-A902-4EF5-9AEE-CF735DF31E35}
{42306484-B2BF-4B52-B950-E0CDFA58B02A} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{286D1FB0-716C-47CB-A519-22E1D34DFDF7} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{F8A4A5C4-86D9-4CF2-A2FC-3B46CCC51750} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{B1792D2A-6D6C-4484-968E-D68DF376BA40} = {3FA3F7B5-5373-4E43-8F45-8EC18249E526}
EndGlobalSection
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.5" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="3.1.5" />
<PackageVersion Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="5.5.0" />
<PackageVersion Include="Microsoft.NetCore.Analyzers" Version="3.0.0" />
<PackageVersion Include="Moq" Version="4.14.5" />
<PackageVersion Include="Shouldly" Version="3.0.2" />
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ If a provider you're looking for does not exist, consider making a PR to add one
| 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") |
| 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") |
| 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") |
| 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") |
| 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") |
| 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") |
| 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") |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<Description>ASP.NET Core security middleware enabling SuperOffice authentication.</Description>
<Authors>Anthony Yates</Authors>
<PackageTags>superoffice;aspnetcore;authentication;oauth;security</PackageTags>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
* for more information concerning the license and the contributors participating to this project.
*/
using Microsoft.AspNetCore.Authentication;

namespace AspNet.Security.OAuth.SuperOffice
{
/// <summary>
/// Contains constants specific to the <see cref="SuperOfficeAuthenticationHandler"/>.
/// </summary>
public static class SuperOfficeAuthenticationConstants
{
public static class ClaimNames
{
/// <summary>
/// Tenant's user identity.
/// </summary>
public const string AssociateId = "http://schemes.superoffice.net/identity/associateid";

/// <summary>
/// Current user's company name.
/// </summary>
public const string CompanyName = "http://schemes.superoffice.net/identity/company_name";

/// <summary>
/// Current user tenant identifier.
/// </summary>
public const string ContextIdentifier = "http://schemes.superoffice.net/identity/ctx";

/// <summary>
/// Current SuperId user email address.
/// </summary>
public const string Email = "http://schemes.superoffice.net/identity/email";

/// <summary>
/// Current user first name.
/// </summary>
public const string FirstName = "http://schemes.superoffice.net/identity/firstname";

/// <summary>
/// SuperOffice identity provider name.
/// </summary>
public const string IdentityProvider = "http://schemes.superoffice.net/identity/identityprovider";

/// <summary>
/// Current user initials.
/// </summary>
public const string Initials = "http://schemes.superoffice.net/identity/initials";

/// <summary>
/// Determines if current user is an administrator.
/// </summary>
public const string IsAdministrator = "http://schemes.superoffice.net/identity/is_administrator";

/// <summary>
/// Current user last name.
/// </summary>
public const string LastName = "http://schemes.superoffice.net/identity/lastname";

/// <summary>
/// Endpoint of SuperOffice SOAP web services.
/// </summary>
public const string NetServerUrl = "http://schemes.superoffice.net/identity/netserver_url";

/// <summary>
/// Tenant database serial number.
/// </summary>
public const string Serial = "http://schemes.superoffice.net/identity/serial";

/// <summary>
/// Current user's tenant primary email address.
/// </summary>
public const string PrimaryEmail = "http://schemes.superoffice.net/identity/so_primary_email_address";

/// <summary>
/// Identifier used to exchange for a system user ticket.
/// </summary>
public const string SystemToken = "http://schemes.superoffice.net/identity/system_token";

/// <summary>
/// Credentials token used to access web services.
/// </summary>
public const string Ticket = "http://schemes.superoffice.net/identity/ticket";

/// <summary>
/// Current user's username.
/// </summary>
public const string UserPrincipalName = "http://schemes.superoffice.net/identity/upn";

/// <summary>
/// Endpoint of SuperOffice REST web services.
/// </summary>
public const string WebApiUrl = "http://schemes.superoffice.net/identity/webapi_url";
}

internal static class FormatStrings
{
/// <summary>
/// A format string used to construct <see cref="SuperOfficeAuthenticationOptions.Authority"/>.
/// </summary>
public const string Authority = "https://{0}.superoffice.com/login";

/// <summary>
/// A format string used to populate OAuth authorize endpoint.
/// </summary>
public const string AuthorizeEndpoint = "https://{0}.superoffice.com/login/common/oauth/authorize";

/// <summary>
/// A format string used to construct <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>.
/// </summary>
public const string ClaimsIssuer = "https://{0}.superoffice.com";

/// <summary>
/// A format string used to construct well-known configuration endpoint.
/// </summary>
public const string MetadataEndpoint = "https://{0}.superoffice.com/login/.well-known/openid-configuration";

/// <summary>
/// A format string used to populate OAuth token endpoint.
/// </summary>
public const string TokenEndpoint = "https://{0}.superoffice.com/login/common/oauth/tokens";

/// <summary>
/// A format string used to obtain user claims.
/// </summary>
/// <remarks>The final user information URL contains the protocol, host and tenant.</remarks>
/// <example>https://sod.superoffice.com/Cust12345/api/v1/user/currentPrincipal</example>
public const string UserInfoEndpoint = "/{0}/api/v1/user/currentPrincipal";
}

public static class PrincipalNames
{
/// <summary>
/// Associate name (e.g. logon name) for the current user.
/// </summary>
public const string Associate = "Associate";

/// <summary>
/// Associate ID for the current user.
/// </summary>
public const string AssociateId = "AssociateId";

/// <summary>
/// Business ID for the company that the user belongs to.
/// </summary>
public const string BusinessId = "BusinessId";

/// <summary>
/// Category ID of the company that the user belongs to.
/// </summary>
public const string CategoryId = "CategoryId";

/// <summary>
/// Company of the associate's person.
/// </summary>
public const string ContactId = "ContactId";

/// <summary>
/// Owner (AssociateId) of the company that the user belongs to.
/// </summary>
public const string ContactOwner = "ContactOwner";

/// <summary>
/// Name of the tenant context identifier.
/// </summary>
public const string ContextIdentifier = "ContextIdentifier";

/// <summary>
/// Country ID for the user.
/// </summary>
public const string CountryId = "CountryId";

/// <summary>
/// Name of the database context.
/// </summary>
public const string DatabaseContextIdentifier = "DatabaseContextIdentifier";

/// <summary>
/// Service user access level.
/// </summary>
public const string EjAccessLevel = "EjAccessLevel";

/// <summary>
/// Primary key in Service user table.
/// </summary>
public const string EjUserId = "EjUserId";

/// <summary>
/// Service user status.
/// </summary>
public const string EjUserStatus = "EjUserStatus";

/// <summary>
/// The Person e-mail address if the associate is a person. Use IsPerson to check.
/// </summary>
public const string EmailAddress = "EMailAddress";

/// <summary>
/// The Person full name if the associate is a person. Use IsPerson to check.
/// </summary>
public const string FullName = "FullName";

/// <summary>
/// Functional rights for the user. This array is sorted.
/// </summary>
public const string FunctionRights = "FunctionRights";

/// <summary>
/// Associate's group ID.
/// </summary>
public const string GroupId = "GroupId";

/// <summary>
/// Country ID for the user's home country. This is the default country ID when creating new items.
/// </summary>
public const string HomeCountryId = "HomeCountryId";

/// <summary>
/// Is this associate a person, and not a resource?
/// </summary>
public const string IsPerson = "IsPerson";

/// <summary>
/// Licenses granted to the site and user.
/// </summary>
public const string Licenses = "Licenses";

/// <summary>
/// Associate's person ID.
/// </summary>
public const string PersonId = "PersonId";

/// <summary>
/// The credentials used for authenticating this user.
/// </summary>
public const string ProvidedCredentials = "ProvidedCredentials";

/// <summary>
/// Description (e.g. tooltip) for the user's role.
/// </summary>
public const string RoleDescription = "RoleDescription";

/// <summary>
/// ID of the user's role.
/// </summary>
public const string RoleId = "RoleId";

/// <summary>
/// Name of the user's role.
/// </summary>
public const string RoleName = "RoleName";

/// <summary>
/// Type of user.
/// </summary>
public const string RoleType = "RoleType";

/// <summary>
/// Secondary user groups.
/// </summary>
public const string SecondaryGroups = "SecondaryGroups";

/// <summary>
/// Type of user.
/// </summary>
public const string UserType = "UserType";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
* for more information concerning the license and the contributors participating to this project.
*/

using Microsoft.AspNetCore.Authentication;

namespace AspNet.Security.OAuth.SuperOffice
{
/// <summary>
/// Default values used by the SuperOffice authentication middleware.
/// </summary>
public static class SuperOfficeAuthenticationDefaults
{
/// <summary>
/// Default value for <see cref="AuthenticationScheme.Name"/>.
/// </summary>
public const string AuthenticationScheme = "SuperOffice";

/// <summary>
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>.
/// </summary>
public const string CallbackPath = "/signin-superoffice";

/// <summary>
/// Default value for <see cref="AuthenticationScheme.DisplayName"/>.
/// </summary>
public static readonly string DisplayName = "SuperOffice";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers
* for more information concerning the license and the contributors participating to this project.
*/

namespace AspNet.Security.OAuth.SuperOffice
{
/// <summary>
/// Used to map usage to specific online environment, i.e. development, stage or production.
/// </summary>
public enum SuperOfficeAuthenticationEnvironment
{
Development,
Stage,
Production
}
}
Loading

0 comments on commit 75ebd13

Please sign in to comment.