-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add OpenId Saturn extension from #139 and talbottmike
- Loading branch information
1 parent
46daf80
commit ce38617
Showing
8 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Auto-Generated by FAKE; do not edit | ||
namespace System | ||
open System.Reflection | ||
|
||
[<assembly: AssemblyTitleAttribute("Saturn.Extensions.OpenIdConnect")>] | ||
[<assembly: AssemblyProductAttribute("Saturn")>] | ||
[<assembly: AssemblyDescriptionAttribute("Opinionated, web development framework for F# which implements the server-side, functional MVC pattern")>] | ||
[<assembly: AssemblyVersionAttribute("0.9.0")>] | ||
[<assembly: AssemblyFileVersionAttribute("0.9.0")>] | ||
do () | ||
|
||
module internal AssemblyVersionInformation = | ||
let [<Literal>] AssemblyTitle = "Saturn.Extensions.OpenIdConnect" | ||
let [<Literal>] AssemblyProduct = "Saturn" | ||
let [<Literal>] AssemblyDescription = "Opinionated, web development framework for F# which implements the server-side, functional MVC pattern" | ||
let [<Literal>] AssemblyVersion = "0.9.0" | ||
let [<Literal>] AssemblyFileVersion = "0.9.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Saturn | ||
|
||
open Saturn | ||
|
||
open Microsoft.AspNetCore.Authentication | ||
open Microsoft.AspNetCore.Authentication.Cookies | ||
open Microsoft.AspNetCore.Authentication.OpenIdConnect | ||
open Microsoft.AspNetCore.Builder | ||
open Microsoft.Extensions.DependencyInjection | ||
|
||
open System | ||
|
||
module OpenId = | ||
let private addCookie state (c:AuthenticationBuilder) = | ||
if not state.CookiesAlreadyAdded then | ||
c.AddCookie() |> ignore | ||
|
||
// Extend Saturn's application { ... } computation expression | ||
type ApplicationBuilder with | ||
/// Enables OpenId authentication with custom configuration | ||
[<CustomOperation("use_open_id_auth_with_config")>] | ||
member __.UseOpenIdAuthWithConfig(state: ApplicationState, (config: Action<OpenIdConnect.OpenIdConnectOptions>)) = | ||
let middleware (app : IApplicationBuilder) = | ||
app.UseAuthentication() | ||
|
||
let service (s: IServiceCollection) = | ||
let authBuilder = s.AddAuthentication(fun authConfig -> | ||
authConfig.DefaultScheme <- CookieAuthenticationDefaults.AuthenticationScheme | ||
authConfig.DefaultChallengeScheme <- OpenIdConnectDefaults.AuthenticationScheme | ||
authConfig.DefaultSignInScheme <- CookieAuthenticationDefaults.AuthenticationScheme) | ||
addCookie state authBuilder | ||
authBuilder.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, config) |> ignore | ||
|
||
s | ||
|
||
{ state with | ||
ServicesConfig = service::state.ServicesConfig | ||
AppConfigs = middleware::state.AppConfigs | ||
CookiesAlreadyAdded = true } |
18 changes: 18 additions & 0 deletions
18
src/Saturn.Extensions.OpenIdConnect/Saturn.Extensions.OpenIdConnect.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Library</OutputType> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<DebugType>portable</DebugType> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Saturn\Saturn.fsproj"> | ||
<Name>Saturn.fsproj</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="OpenId.fs" /> | ||
</ItemGroup> | ||
<Import Project="..\..\.paket\Paket.Restore.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FSharp.Core | ||
Microsoft.AspNetCore.Authentication.OpenIdConnect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
type project | ||
id Saturn.Extensions.gRPC | ||
description | ||
Opinionated, web development framework for F# which implements the server-side, functional MVC pattern | ||
authors | ||
Krzysztof Cieslak | ||
copyright | ||
Copyright 2017 Lambda Factory | ||
summary | ||
Opinionated, web development framework for F# which implements the server-side, functional MVC pattern | ||
licenseurl https://github.com/Krzysztof-Cieslak/Saturn/blob/master/LICENSE.md | ||
projecturl https://github.com/Krzysztof-Cieslak/Saturn | ||
iconurl https://avatars0.githubusercontent.com/u/35305523?s=200&v=4 | ||
include-pdbs true | ||
tags | ||
F#, web, framework, ASP.Net, Core, HTTP, Service, MVC, functional, gRPC |