42 lines
977 B
Plaintext
42 lines
977 B
Plaintext
#r "nuget: Thoth.Json.Net"
|
|
#r "nuget: FSharpPlus"
|
|
|
|
open System
|
|
open Thoth.Json.Net
|
|
open FSharpPlus
|
|
|
|
type Access = {
|
|
matching: string
|
|
group: string
|
|
}
|
|
|
|
type Acl = {
|
|
domain: string
|
|
access: Access[]
|
|
}
|
|
|
|
let file = IO.File.ReadAllText "acl.json"
|
|
|
|
match Decode.Auto.fromString<Acl[]> file with
|
|
| Ok acl ->
|
|
printfn "user_type,user_id,relation,object_type,object_id,condition_name,condition_context"
|
|
acl |> Array.iter (fun x ->
|
|
let a = x.access[0]
|
|
let org = a.group[1 ..]
|
|
printfn $"system,atlantis,parent,organization,{org},,"
|
|
printfn $"organization,{org},parent,group,{a.group},,"
|
|
printfn $"domain,{x.domain},associate,organization,{org},,"
|
|
printfn $"domain,{x.domain},associate,group,{a.group},,"
|
|
printfn $"domain,{x.domain},auto_activate_users,domain,{x.domain},,"
|
|
printfn $"group,{a.group}#member,member,organization,{org},,"
|
|
printfn ""
|
|
)
|
|
| Error e -> printfn $"ERROR: {e}"
|
|
0
|
|
|
|
|
|
|
|
|
|
|
|
|