Skip to content

Commit

Permalink
Add Smartsheet provider (#741)
Browse files Browse the repository at this point in the history
Add Smartsheet provider.
  • Loading branch information
refractivSteve committed Nov 2, 2022
1 parent c9da77a commit 4144056
Show file tree
Hide file tree
Showing 12 changed files with 439 additions and 0 deletions.
8 changes: 8 additions & 0 deletions AspNet.Security.OAuth.Providers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{C2CA4B38-A
docs\reddit.md = docs\reddit.md
docs\salesforce.md = docs\salesforce.md
docs\sign-in-with-apple.md = docs\sign-in-with-apple.md
docs\smartsheet.md = docs\smartsheet.md
docs\snapchat.md = docs\snapchat.md
docs\stackexchange.md = docs\stackexchange.md
docs\superoffice.md = docs\superoffice.md
Expand Down Expand Up @@ -290,6 +291,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Kroge
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Xumm", "src\AspNet.Security.OAuth.Xumm\AspNet.Security.OAuth.Xumm.csproj", "{8E42EF81-A630-4BDB-B642-3F20C863F9BE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Smartsheet", "src\AspNet.Security.OAuth.Smartsheet\AspNet.Security.OAuth.Smartsheet.csproj", "{68862DC5-65B7-4517-B909-AB334F9FCF6E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.Security.OAuth.Huawei", "src\AspNet.Security.OAuth.Huawei\AspNet.Security.OAuth.Huawei.csproj", "{E3CF7FFC-56A0-4033-87A9-BB3080CF030E}"
EndProject
Global
Expand Down Expand Up @@ -666,6 +669,10 @@ Global
{8E42EF81-A630-4BDB-B642-3F20C863F9BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E42EF81-A630-4BDB-B642-3F20C863F9BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E42EF81-A630-4BDB-B642-3F20C863F9BE}.Release|Any CPU.Build.0 = Release|Any CPU
{68862DC5-65B7-4517-B909-AB334F9FCF6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68862DC5-65B7-4517-B909-AB334F9FCF6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68862DC5-65B7-4517-B909-AB334F9FCF6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68862DC5-65B7-4517-B909-AB334F9FCF6E}.Release|Any CPU.Build.0 = Release|Any CPU
{E3CF7FFC-56A0-4033-87A9-BB3080CF030E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3CF7FFC-56A0-4033-87A9-BB3080CF030E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3CF7FFC-56A0-4033-87A9-BB3080CF030E}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -773,6 +780,7 @@ Global
{B8F9B052-84BF-436C-B22B-CEBD5EB1F8E3} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{8C7A98A6-5F61-492B-980D-0A9F5F9F5C73} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{8E42EF81-A630-4BDB-B642-3F20C863F9BE} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{68862DC5-65B7-4517-B909-AB334F9FCF6E} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
{E3CF7FFC-56A0-4033-87A9-BB3080CF030E} = {C1352FD3-AE8B-43EE-B45B-F6E0B3FBAC6D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ If a provider you're looking for does not exist, consider making a PR to add one
| ServiceChannel | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.ServiceChannel?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.ServiceChannel/ "Download AspNet.Security.OAuth.ServiceChannel from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.ServiceChannel?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.ServiceChannel "Download AspNet.Security.OAuth.ServiceChannel from MyGet.org") | [Documentation](https://developer.servicechannel.com/basics/general/authentication "ServiceChannel developer documentation") |
| Shopify | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Shopify?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Shopify/ "Download AspNet.Security.OAuth.Shopify from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Shopify?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Shopify "Download AspNet.Security.OAuth.Shopify from MyGet.org") | [Documentation](https://help.shopify.com/en/api/getting-started/authentication/oauth "Shopify developer documentation") |
| Slack | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Slack?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Slack/ "Download AspNet.Security.OAuth.Slack from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Slack?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Slack "Download AspNet.Security.OAuth.Slack from MyGet.org") | [Documentation](https://api.slack.com/docs/oauth "Slack developer documentation") |
| Smartsheet | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Smartsheet?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Smartsheet/ "Download AspNet.Security.OAuth.Smartsheet from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Smartsheet?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Smartsheet "Download AspNet.Security.OAuth.Smartsheet from MyGet.org") | [Documentation](https://smartsheet.redoc.ly/ "Smartsheet developer documentation") |
| Snapchat | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.Snapchat?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.Snapchat/ "Download AspNet.Security.OAuth.Snapchat from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.Snapchat?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.Snapchat "Download AspNet.Security.OAuth.Snapchat from MyGet.org") | [Documentation](https://marketingapi.snapchat.com/docs/#authentication "Snapchat developer documentation") |
| SoundCloud | [![NuGet](https://buildstats.info/nuget/AspNet.Security.OAuth.SoundCloud?includePreReleases=false)](https://www.nuget.org/packages/AspNet.Security.OAuth.SoundCloud/ "Download AspNet.Security.OAuth.SoundCloud from NuGet.org") | [![MyGet](https://buildstats.info/myget/aspnet-contrib/AspNet.Security.OAuth.SoundCloud?includePreReleases=true)](https://www.myget.org/feed/aspnet-contrib/package/nuget/AspNet.Security.OAuth.SoundCloud "Download AspNet.Security.OAuth.SoundCloud from MyGet.org") | [Documentation](https://developers.soundcloud.com/docs#authentication "SoundCloud developer documentation") |
| 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=true)](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") |
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ covered by the section above.
| QQ | _Optional_ | [Documentation](qq.md "QQ provider documentation") |
| Reddit | _Optional_ | [Documentation](reddit.md "Reddit provider documentation") |
| Salesforce | _Optional_ | [Documentation](salesforce.md "Salesforce provider documentation") |
| Smartsheet | _Optional_ | [Documentation](smartsheet.md "Smartsheet provider documentation") |
| Snapchat | _Optional_ | [Documentation](snapchat.md "Snapchat provider documentation") |
| StackExchange | _Optional_ | [Documentation](stackexchange.md "StackExchange provider documentation") |
| SuperOffice | **Required** | [Documentation](superoffice.md "SuperOffice provider documentation") |
Expand Down
23 changes: 23 additions & 0 deletions docs/smartsheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Integrating the Smartsheet Provider

## Example

```csharp
services.AddAuthentication(options => /* Auth configuration */)
.AddSmartsheet(options =>
{
options.ClientId = "my-client-id";
options.ClientSecret = "my-client-secret";

// At least one scope must be passed
options.Scope.Add("READ_SHEETS");
});
```

## Required Additional Settings

_None._

## Optional Settings

_None._
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFramework)</TargetFrameworks>
<PackageValidationBaselineVersion>6.0.14</PackageValidationBaselineVersion>
</PropertyGroup>

<PropertyGroup>
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
</PropertyGroup>

<PropertyGroup>
<Description>ASP.NET Core security middleware enabling Smartsheet authentication.</Description>
<Authors>Steve Albison</Authors>
<PackageTags>aspnetcore;authentication;oauth;smartsheet;security</PackageTags>
</PropertyGroup>

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

</Project>
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.Smartsheet;

/// <summary>
/// Contains constants specific to the <see cref="SmartsheetAuthenticationHandler"/>.
/// </summary>
public static class SmartsheetAuthenticationConstants
{
public static class Claims
{
public const string ProfileImage = "urn:smartsheet:profileimage";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.Smartsheet;

/// <summary>
/// Default values used by the Smartsheet authentication middleware.
/// </summary>
public static class SmartsheetAuthenticationDefaults
{
/// <summary>
/// Default value for <see cref="AuthenticationScheme.Name"/>.
/// </summary>
public const string AuthenticationScheme = "Smartsheet";

/// <summary>
/// Default value for <see cref="AuthenticationScheme.DisplayName"/>.
/// </summary>
public static readonly string DisplayName = "Smartsheet";

/// <summary>
/// Default value for <see cref="AuthenticationSchemeOptions.ClaimsIssuer"/>.
/// </summary>
public static readonly string Issuer = "Smartsheet";

/// <summary>
/// Default value for <see cref="RemoteAuthenticationOptions.CallbackPath"/>.
/// </summary>
public static readonly string CallbackPath = "/signin-smartsheet";

/// <summary>
/// Default value for <see cref="OAuthOptions.AuthorizationEndpoint"/>.
/// </summary>
public static readonly string AuthorizationEndpoint = "https://app.smartsheet.com/b/authorize";

/// <summary>
/// Format value for <see cref="OAuthOptions.TokenEndpoint"/>.
/// </summary>
public static readonly string TokenEndpoint = "https://api.smartsheet.com/2.0/token";

/// <summary>
/// Default value for <see cref="OAuthOptions.UserInformationEndpoint"/>.
/// </summary>
public static readonly string UserInformationEndpoint = "https://api.smartsheet.com/2.0/users/me";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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 AspNet.Security.OAuth.Smartsheet;

namespace Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Extension methods to add Smartsheet authentication capabilities to an HTTP application pipeline.
/// </summary>
public static class SmartsheetAuthenticationExtensions
{
/// <summary>
/// Adds <see cref="SmartsheetAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables Smartsheet authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddSmartsheet([NotNull] this AuthenticationBuilder builder)
{
return builder.AddSmartsheet(SmartsheetAuthenticationDefaults.AuthenticationScheme, options => { });
}

/// <summary>
/// Adds <see cref="SmartsheetAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables Smartsheet authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <param name="configuration">The delegate used to configure the OpenID 2.0 options.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddSmartsheet(
[NotNull] this AuthenticationBuilder builder,
[NotNull] Action<SmartsheetAuthenticationOptions> configuration)
{
return builder.AddSmartsheet(SmartsheetAuthenticationDefaults.AuthenticationScheme, configuration);
}

/// <summary>
/// Adds <see cref="SmartsheetAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables Smartsheet authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <param name="scheme">The authentication scheme associated with this instance.</param>
/// <param name="configuration">The delegate used to configure the Smartsheet options.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddSmartsheet(
[NotNull] this AuthenticationBuilder builder,
[NotNull] string scheme,
[NotNull] Action<SmartsheetAuthenticationOptions> configuration)
{
return builder.AddSmartsheet(scheme, SmartsheetAuthenticationDefaults.DisplayName, configuration);
}

/// <summary>
/// Adds <see cref="SmartsheetAuthenticationHandler"/> to the specified
/// <see cref="AuthenticationBuilder"/>, which enables Smartsheet authentication capabilities.
/// </summary>
/// <param name="builder">The authentication builder.</param>
/// <param name="scheme">The authentication scheme associated with this instance.</param>
/// <param name="caption">The optional display name associated with this instance.</param>
/// <param name="configuration">The delegate used to configure the Smartsheet options.</param>
/// <returns>The <see cref="AuthenticationBuilder"/>.</returns>
public static AuthenticationBuilder AddSmartsheet(
[NotNull] this AuthenticationBuilder builder,
[NotNull] string scheme,
[CanBeNull] string caption,
[NotNull] Action<SmartsheetAuthenticationOptions> configuration)
{
return builder.AddOAuth<SmartsheetAuthenticationOptions, SmartsheetAuthenticationHandler>(scheme, caption, configuration);
}
}
Loading

0 comments on commit 4144056

Please sign in to comment.