Last active
February 13, 2022 21:55
-
-
Save xperiandri/32a6878b4d95f6c40cf2cc98b60f5d81 to your computer and use it in GitHub Desktop.
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
type WebJobsHttpExtensionStartup () = | |
interface IWebJobsStartup with | |
member __.Configure (builder : IWebJobsBuilder) = | |
builder.Services | |
.AddScoped<Lazy<Result<GraphQLUser, Errors.ErrorMessage>>>( | |
fun provider -> Control.Lazy.Create(fun () -> WebJobsHttpExtensionStartup.GetUserIdResultFromClaims provider)) | |
.AddAuthorizationWithReflection (fun options -> | |
options.AddPolicy(Policies.EditBooks, | |
fun policy -> policy.Requirements.Add( | |
AllowedGroupRequierment (Seq.singleton ActiveDirectoryGroups.BookEditors))) | |
options.AddPolicy(Policies.ViewBooks, | |
fun policy -> policy.Requirements.Add( | |
AllowedGroupRequierment (seq { | |
yield ActiveDirectoryGroups.BookEditors | |
yield ActiveDirectoryGroups.BooksViewers | |
}))) | |
options.AddPolicy(Policies.ViewUsers, | |
fun policy -> policy.Requirements.Add( | |
AllowedGroupRequierment (Seq.singleton ActiveDirectoryGroups.UserViewers)))) | |
.AddScoped<IAuthorizationHandler, AllowedGroupHandler>() | |
.AddScoped<IAuthorizationHandler, AllowedGroupAdminHandler>() | |
|> ignore | |
() | |
[<assembly: WebJobsStartup(typeof<WebJobsHttpExtensionStartup>, "Http Extension")>] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment