Skip to content

Commit 1ffa5a2

Browse files
authored
Merge pull request #59 from passbolt/v5-schema-fixes
V5 schema fixes
2 parents 9c9e233 + 1111e12 commit 1ffa5a2

File tree

2 files changed

+41
-47
lines changed

2 files changed

+41
-47
lines changed

api/schema.go

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,19 @@ var ResourceSchemas = map[string]json.RawMessage{
1515
"maxLength": 255
1616
},
1717
"username": {
18-
"type": "string",
19-
"maxLength": 255,
20-
"nullable": true
18+
"type": ["string", "null"],
19+
"maxLength": 255
2120
},
2221
"uris": {
2322
"type": "array",
2423
"items": {
2524
"type": "string",
26-
"maxLength": 1024,
27-
"nullable": true
25+
"maxLength": 1024
2826
}
2927
},
3028
"description": {
31-
"type": "string",
32-
"maxLength": 10000,
33-
"nullable": true
29+
"type": ["string", "null"],
30+
"maxLength": 10000
3431
}
3532
}
3633
},
@@ -43,14 +40,12 @@ var ResourceSchemas = map[string]json.RawMessage{
4340
"enum": ["PASSBOLT_SECRET_DATA"]
4441
},
4542
"password": {
46-
"type": "string",
47-
"maxLength": 4096,
48-
"nullable": true
43+
"type": ["string", "null"],
44+
"maxLength": 4096
4945
},
5046
"description": {
51-
"type": "string",
52-
"maxLength": 10000,
53-
"nullable": true
47+
"type": ["string", "null"],
48+
"maxLength": 10000
5449
}
5550
}
5651
}
@@ -66,22 +61,19 @@ var ResourceSchemas = map[string]json.RawMessage{
6661
"maxLength": 255
6762
},
6863
"username": {
69-
"type": "string",
70-
"maxLength": 255,
71-
"nullable": true
64+
"type": ["string", "null"],
65+
"maxLength": 255
7266
},
7367
"uris": {
7468
"type": "array",
7569
"items": {
7670
"type": "string",
77-
"maxLength": 1024,
78-
"nullable": true
71+
"maxLength": 1024
7972
}
8073
},
8174
"description": {
82-
"type": "string",
83-
"maxLength": 10000,
84-
"nullable": true
75+
"type": ["string", "null"],
76+
"maxLength": 10000
8577
}
8678
}
8779
},
@@ -101,22 +93,19 @@ var ResourceSchemas = map[string]json.RawMessage{
10193
"maxLength": 255
10294
},
10395
"username": {
104-
"type": "string",
105-
"maxLength": 255,
106-
"nullable": true
96+
"type": ["string", "null"],
97+
"maxLength": 255
10798
},
10899
"uris": {
109100
"type": "array",
110101
"items": {
111102
"type": "string",
112-
"maxLength": 1024,
113-
"nullable": true
103+
"maxLength": 1024
114104
}
115105
},
116106
"description": {
117-
"type": "string",
118-
"maxLength": 10000,
119-
"nullable": true
107+
"type": ["string", "null"],
108+
"maxLength": 10000
120109
}
121110
}
122111
},
@@ -129,14 +118,12 @@ var ResourceSchemas = map[string]json.RawMessage{
129118
"enum": ["PASSBOLT_SECRET_DATA"]
130119
},
131120
"password": {
132-
"type": "string",
133-
"maxLength": 4096,
134-
"nullable": true
121+
"type": ["string", "null"],
122+
"maxLength": 4096
135123
},
136124
"description": {
137-
"type": "string",
138-
"maxLength": 10000,
139-
"nullable": true
125+
"type": ["string", "null"],
126+
"maxLength": 10000
140127
},
141128
"totp": {
142129
"type": "object",
@@ -174,23 +161,16 @@ var ResourceSchemas = map[string]json.RawMessage{
174161
"type": "string",
175162
"maxLength": 255
176163
},
177-
"username": {
178-
"type": "string",
179-
"maxLength": 255,
180-
"nullable": true
181-
},
182164
"uris": {
183165
"type": "array",
184166
"items": {
185167
"type": "string",
186-
"maxLength": 1024,
187-
"nullable": true
168+
"maxLength": 1024
188169
}
189170
},
190171
"description": {
191-
"type": "string",
192-
"maxLength": 10000,
193-
"nullable": true
172+
"type": ["string", "null"],
173+
"maxLength": 10000
194174
}
195175
}
196176
},

helper/resource_get.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,21 @@ func GetResourceFromData(c *api.Client, resource api.Resource, secret api.Secret
173173

174174
pw = rawSecretData
175175
case "v5-totp-standalone":
176-
// nothing fits into the interface in this case
176+
rawMetadata, err := GetResourceMetadata(ctx, c, &resource, &rType)
177+
if err != nil {
178+
return "", "", "", "", "", "", fmt.Errorf("Getting Metadata: %w", err)
179+
}
180+
181+
var metadata api.ResourceMetadataTypeV5TOTPStandalone
182+
err = json.Unmarshal([]byte(rawMetadata), &metadata)
183+
if err != nil {
184+
return "", "", "", "", "", "", fmt.Errorf("Parsing Decrypted Metadata: %w", err)
185+
}
186+
187+
name = metadata.Name
188+
if len(metadata.URIs) != 0 {
189+
uri = metadata.URIs[0]
190+
}
177191
default:
178192
return "", "", "", "", "", "", fmt.Errorf("Unknown ResourceType: %v", rType.Slug)
179193
}

0 commit comments

Comments
 (0)