this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

lexicon: more permission set support

+60 -8
+17 -2
atproto/lexicon/language.go
··· 404 404 405 405 type SchemaPermissionSet struct { 406 406 Type string `json:"type"` // "permission-set" 407 - Description *string `json:"description,omitempty"` 407 + Title *string `json:"title,omitempty"` 408 + TitleLangs map[string]string `json:"title:langs,omitempty"` 409 + Detail *string `json:"detail,omitempty"` 410 + DetailLangs map[string]string `json:"detail:langs,omitempty"` 408 411 Permissions []SchemaPermission `json:"permissions"` 409 412 } 410 413 411 414 func (s *SchemaPermissionSet) CheckSchema() error { 415 + for lang, _ := range s.TitleLangs { 416 + _, err := syntax.ParseLanguage(lang) 417 + if err != nil { 418 + return err 419 + } 420 + } 421 + for lang, _ := range s.DetailLangs { 422 + _, err := syntax.ParseLanguage(lang) 423 + if err != nil { 424 + return err 425 + } 426 + } 412 427 for _, p := range s.Permissions { 413 428 if err := p.CheckSchema(); err != nil { 414 429 return err ··· 484 499 if (s.InheritAud == true && s.Audience != "") || (s.InheritAud == false && s.Audience == "") { 485 500 return fmt.Errorf("rpc permission must have eith 'aud' or 'inheritAud' defined") 486 501 } 487 - if s.Audience != "" { 502 + if s.Audience != "" && s.Audience != "*" { 488 503 // TODO: helper for service refs 489 504 parts := strings.SplitN(s.Audience, "#", 3) 490 505 if len(parts) != 2 || parts[1] == "" {
+43 -6
atproto/lexicon/testdata/catalog/permission-set.json
··· 1 1 { 2 2 "lexicon": 1, 3 3 "id": "example.lexicon.permissionset", 4 - "description": "exercizes many lexicon features for the permission-set type", 4 + "description": "exercises many lexicon features for the permission-set type", 5 5 "defs": { 6 6 "main": { 7 7 "type": "permission-set", 8 + "title": "Example for Moderation", 9 + "title:lang": { 10 + "fr": "Example for Modération" 11 + }, 12 + "detail": "Create moderation reports", 13 + "detail:lang": { 14 + "fr-FR": "Créer des rapports de modération" 15 + }, 8 16 "permissions": [ 9 17 { 10 18 "type": "permission", 11 19 "resource": "blob", 12 20 "accept": [ 13 - "image/*" 21 + "image/*", 22 + "video/*" 14 23 ] 15 24 }, 16 25 { ··· 39 48 ] 40 49 }, 41 50 { 42 - "type": "permission", 43 - "resource": "rpc", 44 - "aud": "did:web:example.com#foo", 45 - "lxm": ["com.example.calendar.listEvents"] 51 + "type": "permission", 52 + "resource": "repo", 53 + "collection": [ 54 + "com.example.calendar.eventV2" 55 + ], 56 + "action": [ 57 + "create" 58 + ] 59 + }, 60 + { 61 + "type": "permission", 62 + "resource": "rpc", 63 + "aud": "did:web:example.com#foo", 64 + "lxm": [ 65 + "com.example.calendar.listEvents" 66 + ] 67 + }, 68 + { 69 + "type": "permission", 70 + "resource": "rpc", 71 + "aud": "did:web:example.com#bar", 72 + "lxm": [ 73 + "*" 74 + ] 46 75 }, 47 76 { 48 77 "type": "permission", 49 78 "resource": "rpc", 50 79 "inheritAud": true, 80 + "lxm": [ 81 + "com.example.calendar.listEvents" 82 + ] 83 + }, 84 + { 85 + "type": "permission", 86 + "resource": "rpc", 87 + "aud": "*", 51 88 "lxm": [ 52 89 "com.example.calendar.listEvents" 53 90 ]