diff --git a/src/Gemstone.Web/Gemstone.Web.csproj b/src/Gemstone.Web/Gemstone.Web.csproj index ea7ad148..f305c898 100644 --- a/src/Gemstone.Web/Gemstone.Web.csproj +++ b/src/Gemstone.Web/Gemstone.Web.csproj @@ -65,6 +65,7 @@ + diff --git a/src/Gemstone.Web/Security/IAuthenticationWebBuilder.cs b/src/Gemstone.Web/Security/IAuthenticationWebBuilder.cs index e2f0f500..32042eac 100644 --- a/src/Gemstone.Web/Security/IAuthenticationWebBuilder.cs +++ b/src/Gemstone.Web/Security/IAuthenticationWebBuilder.cs @@ -192,6 +192,30 @@ public static AuthenticationBuilder ConfigureGemstoneWebAuthentication(this ISer .ConfigureGemstoneWebDefaults(); } + /// + /// Configures an authentication provider that uses OAuth to authenticate users. + /// + /// The authentication builder for the application + /// The options to configure the OAuth provider + /// The authentication builder for the application. + public static AuthenticationBuilder ConfigureOAuthProvider(this AuthenticationBuilder builder, OAuthAuthenticationProviderOptions providerOptions) + { + builder.Services.AddOAuthAuthenticationProvider(providerOptions); + + return builder.AddOpenIdConnect("oauth", config => + { + config.Authority = providerOptions.Authority; + config.ClientId = providerOptions.ClientId; + config.ClientSecret = providerOptions.ClientSecret; + config.CallbackPath = "/index.html"; + + config.Scope.Add("openid"); + + foreach (string scope in providerOptions.Scopes.Split(' ', StringSplitOptions.RemoveEmptyEntries)) + config.Scope.Add(scope); + }); + } + /// /// Automatically configures the request pipeline to support well-known authentication providers. ///