Skip to content

Commit a26eac5

Browse files
committed
WIP
1 parent d259c05 commit a26eac5

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

coderd/apidoc/docs.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ const docTemplate = `{
726726
]
727727
},
728728
"object": {
729-
"description": "Object can represent a \"set\" of objects, such as:\n\t- All workspaces in an organization\n\t- All workspaces owned by me\n\t- All workspaces across the entire product\nWhen defining an object, use the most specific language when possible to\nproduce the smallest set. Meaning to set as many fields on 'Object' as\nyou can. Example, if you want to check if you can update all workspaces\nowned by 'me', try to also add an 'OrganizationID' to the settings.\nOmitting the 'OrganizationID' could produce the incorrect value, as\nworkspaces have both ` + "`" + `user` + "`" + ` and ` + "`" + `organization` + "`" + ` owners.",
729+
"description": "Object can represent a \"set\" of objects, such as: all workspaces in an organization, all workspaces owned by me, all workspaces across the entire product.",
730730
"$ref": "#/definitions/codersdk.AuthorizationObject"
731731
}
732732
}
@@ -735,15 +735,15 @@ const docTemplate = `{
735735
"type": "object",
736736
"properties": {
737737
"organization_id": {
738-
"description": "OrganizationID (optional) is an organization_id. It adds the set constraint to\nall resources owned by a given organization.",
738+
"description": "Organization ID (optional) adds the set constraint to all resources owned by a given organization.",
739739
"type": "string"
740740
},
741741
"owner_id": {
742-
"description": "OwnerID (optional) is a user_id. It adds the set constraint to all resources owned\nby a given user.",
742+
"description": "OwnerID (optional) adds the set constraint to all resources owned by a given user.",
743743
"type": "string"
744744
},
745745
"resource_id": {
746-
"description": "ResourceID (optional) reduces the set to a singular resource. This assigns\na resource ID to the resource type, eg: a single workspace.\nThe rbac library will not fetch the resource from the database, so if you\nare using this option, you should also set the 'OwnerID' and 'OrganizationID'\nif possible. Be as specific as possible using all the fields relevant.",
746+
"description": "ResourceID (optional) reduces the set to a singular resource. This assigns\na resource ID to the resource type, eg: a single workspace.\nThe rbac library will not fetch the resource from the database, so if you\nare using this option, you should also set the ` + "`" + `OwnerID` + "`" + ` and ` + "`" + `OrganizationID` + "`" + `\nif possible. Be as specific as possible using all the fields relevant.",
747747
"type": "string"
748748
},
749749
"resource_type": {

coderd/apidoc/swagger.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@
642642
"enum": ["create", "read", "update", "delete"]
643643
},
644644
"object": {
645-
"description": "Object can represent a \"set\" of objects, such as:\n\t- All workspaces in an organization\n\t- All workspaces owned by me\n\t- All workspaces across the entire product\nWhen defining an object, use the most specific language when possible to\nproduce the smallest set. Meaning to set as many fields on 'Object' as\nyou can. Example, if you want to check if you can update all workspaces\nowned by 'me', try to also add an 'OrganizationID' to the settings.\nOmitting the 'OrganizationID' could produce the incorrect value, as\nworkspaces have both `user` and `organization` owners.",
645+
"description": "Object can represent a \"set\" of objects, such as: all workspaces in an organization, all workspaces owned by me, all workspaces across the entire product.",
646646
"$ref": "#/definitions/codersdk.AuthorizationObject"
647647
}
648648
}
@@ -651,15 +651,15 @@
651651
"type": "object",
652652
"properties": {
653653
"organization_id": {
654-
"description": "OrganizationID (optional) is an organization_id. It adds the set constraint to\nall resources owned by a given organization.",
654+
"description": "Organization ID (optional) adds the set constraint to all resources owned by a given organization.",
655655
"type": "string"
656656
},
657657
"owner_id": {
658-
"description": "OwnerID (optional) is a user_id. It adds the set constraint to all resources owned\nby a given user.",
658+
"description": "OwnerID (optional) adds the set constraint to all resources owned by a given user.",
659659
"type": "string"
660660
},
661661
"resource_id": {
662-
"description": "ResourceID (optional) reduces the set to a singular resource. This assigns\na resource ID to the resource type, eg: a single workspace.\nThe rbac library will not fetch the resource from the database, so if you\nare using this option, you should also set the 'OwnerID' and 'OrganizationID'\nif possible. Be as specific as possible using all the fields relevant.",
662+
"description": "ResourceID (optional) reduces the set to a singular resource. This assigns\na resource ID to the resource type, eg: a single workspace.\nThe rbac library will not fetch the resource from the database, so if you\nare using this option, you should also set the `OwnerID` and `OrganizationID`\nif possible. Be as specific as possible using all the fields relevant.",
663663
"type": "string"
664664
},
665665
"resource_type": {

codersdk/authorization.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,30 @@ type AuthorizationRequest struct {
2323
// AuthorizationCheck is used to check if the currently authenticated user (or
2424
// the specified user) can do a given action to a given set of objects.
2525
type AuthorizationCheck struct {
26-
// Object can represent a "set" of objects, such as:
27-
// - All workspaces in an organization
28-
// - All workspaces owned by me
29-
// - All workspaces across the entire product
30-
// When defining an object, use the most specific language when possible to
31-
// produce the smallest set. Meaning to set as many fields on 'Object' as
32-
// you can. Example, if you want to check if you can update all workspaces
33-
// owned by 'me', try to also add an 'OrganizationID' to the settings.
34-
// Omitting the 'OrganizationID' could produce the incorrect value, as
35-
// workspaces have both `user` and `organization` owners.
26+
// Object can represent a "set" of objects, such as: all workspaces in an organization, all workspaces owned by me, all workspaces across the entire product.
3627
Object AuthorizationObject `json:"object"`
3728
// Action can be `create`, `read`, `update`, or `delete`
3829
Action string `json:"action" enums:"create,read,update,delete"`
3930
}
4031

32+
// AuthorizationObject: when defining, use the most specific language when possible to
33+
// produce the smallest set. Meaning to set as many fields on `Object` as
34+
// you can. Example, if you want to check if you can update all workspaces
35+
// owned by `me`, try to also add an `OrganizationID` to the settings.
36+
// Omitting the `OrganizationID` could produce the incorrect value, as
37+
// workspaces have both `user` and `organization` owners.
4138
type AuthorizationObject struct {
4239
// ResourceType is the name of the resource.
4340
// `./coderd/rbac/object.go` has the list of valid resource types.
4441
ResourceType string `json:"resource_type"`
45-
// OwnerID (optional) is a user_id. It adds the set constraint to all resources owned
46-
// by a given user.
42+
// OwnerID (optional) adds the set constraint to all resources owned by a given user.
4743
OwnerID string `json:"owner_id,omitempty"`
48-
// OrganizationID (optional) is an organization_id. It adds the set constraint to
49-
// all resources owned by a given organization.
44+
// Organization ID (optional) adds the set constraint to all resources owned by a given organization.
5045
OrganizationID string `json:"organization_id,omitempty"`
5146
// ResourceID (optional) reduces the set to a singular resource. This assigns
5247
// a resource ID to the resource type, eg: a single workspace.
5348
// The rbac library will not fetch the resource from the database, so if you
54-
// are using this option, you should also set the 'OwnerID' and 'OrganizationID'
49+
// are using this option, you should also set the `OwnerID` and `OrganizationID`
5550
// if possible. Be as specific as possible using all the fields relevant.
5651
ResourceID string `json:"resource_id,omitempty"`
5752
}

docs/api/schemas.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747

4848
| Name | Type | Required | Restrictions | Description |
4949
| ----------------- | ------ | -------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
50-
| `organization_id` | string | false | none | Organization id (optional) is an organization_id. It adds the set constraint to<br>all resources owned by a given organization. |
51-
| `owner_id` | string | false | none | Owner id (optional) is a user_id. It adds the set constraint to all resources owned<br>by a given user. |
52-
| `resource_id` | string | false | none | Resource id (optional) reduces the set to a singular resource. This assigns<br>a resource ID to the resource type, eg: a single workspace.<br>The rbac library will not fetch the resource from the database, so if you<br>are using this option, you should also set the 'OwnerID' and 'OrganizationID'<br>if possible. Be as specific as possible using all the fields relevant. |
50+
| `organization_id` | string | false | none | Organization ID (optional) adds the set constraint to all resources owned by a given organization. |
51+
| `owner_id` | string | false | none | Owner id (optional) adds the set constraint to all resources owned by a given user. |
52+
| `resource_id` | string | false | none | Resource id (optional) reduces the set to a singular resource. This assigns<br>a resource ID to the resource type, eg: a single workspace.<br>The rbac library will not fetch the resource from the database, so if you<br>are using this option, you should also set the `OwnerID` and `OrganizationID`<br>if possible. Be as specific as possible using all the fields relevant. |
5353
| `resource_type` | string | false | none | Resource type is the name of the resource.<br>`./coderd/rbac/object.go` has the list of valid resource types. |
5454

5555
## codersdk.AuthorizationRequest

0 commit comments

Comments
 (0)