| 1 | package accesscontrolscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ |
| 2 | |
| 3 | import ( |
| 4 | "stringsscip-go gomod github.com/golang/go/src go1.13 strings/" |
| 5 | ) |
| 6 | |
| 7 | type ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL# struct { |
| 8 | Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries. []ACEscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE# |
| 9 | } |
| 10 | |
| 11 | // Validate checks the ACL. Returns nil on success |
| 12 | func (acl *ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#) Validatescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Validate().() error { |
| 13 | |
| 14 | // TODO |
| 15 | // - check each user/group is only listed once (per default/non-default) |
| 16 | |
| 17 | for _, v := range acl.Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries. { |
| 18 | if err := v.Validatescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Validate().(); err != nil { |
| 19 | return err |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | return nil |
| 24 | } |
| 25 | |
| 26 | // ParseACL parses an ACL string |
| 27 | func ParseACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ParseACL().(input string) (ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#, error) { |
| 28 | |
| 29 | aceStrings := stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Splitscip-go gomod github.com/golang/go/src go1.13 strings/Split().(input, ",") |
| 30 | entries := make([]ACEscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#, len(aceStrings)) |
| 31 | |
| 32 | for i := 0; i < len(aceStrings); i++ { |
| 33 | aceString := aceStrings[i] |
| 34 | entry, err := ParseACEscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ParseACE().(aceString) |
| 35 | if err != nil { |
| 36 | return ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#{}, err |
| 37 | } |
| 38 | entries[i] = entry |
| 39 | } |
| 40 | return ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#{Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries.: entries}, nil |
| 41 | } |
| 42 | |
| 43 | // String returns the string form of the ACL - this does not check that it is valid |
| 44 | func (acl *ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#) Stringscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#String().() string { |
| 45 | |
| 46 | aceStrings := make([]string, len(acl.Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries.)) |
| 47 | |
| 48 | for i := 0; i < len(acl.Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries.); i++ { |
| 49 | ace := acl.Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries.[i] |
| 50 | aceStrings[i] = ace.Stringscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#String().() |
| 51 | } |
| 52 | return stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Joinscip-go gomod github.com/golang/go/src go1.13 strings/Join().(aceStrings, ",") |
| 53 | } |