Skip to content

Commit

Permalink
Marshal bool as bool and fix schema validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
russjones committed Aug 8, 2018
1 parent 85d34ac commit 757db0b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/services/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@ const MetadataSchema = `{
"expires": {"type": "string"},
"labels": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z/.0-9_]$": { "type": "string" }
"^[a-zA-Z/.0-9_*]+$": { "type": "string" }
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions lib/services/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -1750,9 +1750,9 @@ func (b Bool) Value() bool {
return b.bool
}

// MarshalJSON marshals Duration to string
// MarshalJSON marshals boolean value.
func (b Bool) MarshalJSON() ([]byte, error) {
return json.Marshal(fmt.Sprintf("%t", b.bool))
return json.Marshal(b.bool)
}

// UnmarshalJSON unmarshals JSON from string or bool,
Expand Down Expand Up @@ -1868,8 +1868,14 @@ const RoleSpecV3SchemaTemplate = `{
"max_session_ttl": { "type": "string" },
"options": {
"type": "object",
"patternProperties": {
"^[a-zA-Z/.0-9_]$": { "type": "string" }
"additionalProperties": false,
"properties": {
"forward_agent": { "type": ["boolean", "string"] },
"max_session_ttl": { "type": "string" },
"port_forwarding": { "type": ["boolean", "string"] },
"cert_format": { "type": "string" },
"client_idle_timeout": { "type": "string" },
"disconnect_expired_cert": { "type": ["boolean", "string"] }
}
},
"allow": { "$ref": "#/definitions/role_condition" },
Expand All @@ -1887,8 +1893,9 @@ const RoleSpecV3SchemaDefinitions = `
},
"node_labels": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z/.0-9_]$": { "type": "string" }
"^[a-zA-Z/.0-9_*]+$": { "type": "string" }
}
},
"logins": {
Expand Down
2 changes: 2 additions & 0 deletions lib/services/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,14 @@ const ServerSpecV2Schema = `{
"hostname": {"type": "string"},
"labels": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^.*$": { "type": "string" }
}
},
"cmd_labels": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^.*$": {
"type": "object",
Expand Down
8 changes: 7 additions & 1 deletion lib/services/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,14 @@ const UserSpecV2SchemaTemplate = `{
},
"traits": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z/.0-9_]$": { "type": "array", "items": {"type": "string"} }
"^[a-zA-Z/.0-9_]+$": {
"type": ["array", "null"],
"items": {
"type": "string"
}
}
}
},
"oidc_identities": {
Expand Down

0 comments on commit 757db0b

Please sign in to comment.