Skip to content

docs: applications and authorization #5477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
mtojek committed Dec 20, 2022
commit 9950d35b41ecc8a6856818dc747be03b83b6964f
3 changes: 1 addition & 2 deletions coderd/apidoc/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,6 @@ const docTemplate = `{
"type": "object",
"properties": {
"action": {
"description": "Action can be ` + "`" + `create` + "`" + `, ` + "`" + `read` + "`" + `, ` + "`" + `update` + "`" + `, or ` + "`" + `delete` + "`" + `",
"type": "string",
"enum": [
"create",
Expand All @@ -726,7 +725,7 @@ const docTemplate = `{
]
},
"object": {
"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.",
"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.",
"$ref": "#/definitions/codersdk.AuthorizationObject"
}
}
Expand Down
3 changes: 1 addition & 2 deletions coderd/apidoc/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,11 @@
"type": "object",
"properties": {
"action": {
"description": "Action can be `create`, `read`, `update`, or `delete`",
"type": "string",
"enum": ["create", "read", "update", "delete"]
},
"object": {
"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.",
"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.",
"$ref": "#/definitions/codersdk.AuthorizationObject"
}
}
Expand Down
20 changes: 11 additions & 9 deletions codersdk/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ type AuthorizationRequest struct {
// AuthorizationCheck is used to check if the currently authenticated user (or
// the specified user) can do a given action to a given set of objects.
type AuthorizationCheck struct {
// 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.
// 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
// When defining an object, use the most specific language when possible to
// produce the smallest set. Meaning to set as many fields on 'Object' as
// you can. Example, if you want to check if you can update all workspaces
// owned by 'me', try to also add an 'OrganizationID' to the settings.
// Omitting the 'OrganizationID' could produce the incorrect value, as
// workspaces have both `user` and `organization` owners.
Object AuthorizationObject `json:"object"`
// Action can be `create`, `read`, `update`, or `delete`
Action string `json:"action" enums:"create,read,update,delete"`
Action string `json:"action" enums:"create,read,update,delete"`
}

// AuthorizationObject: when defining, use the most specific language when possible to
// produce the smallest set. Meaning to set as many fields on `Object` as
// you can. Example, if you want to check if you can update all workspaces
// owned by `me`, try to also add an `OrganizationID` to the settings.
// Omitting the `OrganizationID` could produce the incorrect value, as
// workspaces have both `user` and `organization` owners.
type AuthorizationObject struct {
// ResourceType is the name of the resource.
// `./coderd/rbac/object.go` has the list of valid resource types.
Expand Down
8 changes: 4 additions & 4 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

### Properties

| Name | Type | Required | Restrictions | Description |
| -------- | ------------------------------------------------------------ | -------- | ------------ | ----------------------------------------------------- |
| `action` | string | false | none | Action can be `create`, `read`, `update`, or `delete` |
| `object` | [codersdk.AuthorizationObject](#codersdkauthorizationobject) | false | none | none |
| Name | Type | Required | Restrictions | Description |
| -------- | ------------------------------------------------------------ | -------- | ------------ | ----------- |
| `action` | string | false | none | none |
| `object` | [codersdk.AuthorizationObject](#codersdkauthorizationobject) | false | none | none |

#### Enumerated Values

Expand Down