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 a26eac54d46ecf6de2aeebda312a0cdaf0640f17
8 changes: 4 additions & 4 deletions coderd/apidoc/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ const docTemplate = `{
]
},
"object": {
"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.",
"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.",
"$ref": "#/definitions/codersdk.AuthorizationObject"
}
}
Expand All @@ -735,15 +735,15 @@ const docTemplate = `{
"type": "object",
"properties": {
"organization_id": {
"description": "OrganizationID (optional) is an organization_id. It adds the set constraint to\nall resources owned by a given organization.",
"description": "Organization ID (optional) adds the set constraint to all resources owned by a given organization.",
"type": "string"
},
"owner_id": {
"description": "OwnerID (optional) is a user_id. It adds the set constraint to all resources owned\nby a given user.",
"description": "OwnerID (optional) adds the set constraint to all resources owned by a given user.",
"type": "string"
},
"resource_id": {
"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.",
"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.",
"type": "string"
},
"resource_type": {
Expand Down
8 changes: 4 additions & 4 deletions coderd/apidoc/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@
"enum": ["create", "read", "update", "delete"]
},
"object": {
"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.",
"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.",
"$ref": "#/definitions/codersdk.AuthorizationObject"
}
}
Expand All @@ -651,15 +651,15 @@
"type": "object",
"properties": {
"organization_id": {
"description": "OrganizationID (optional) is an organization_id. It adds the set constraint to\nall resources owned by a given organization.",
"description": "Organization ID (optional) adds the set constraint to all resources owned by a given organization.",
"type": "string"
},
"owner_id": {
"description": "OwnerID (optional) is a user_id. It adds the set constraint to all resources owned\nby a given user.",
"description": "OwnerID (optional) adds the set constraint to all resources owned by a given user.",
"type": "string"
},
"resource_id": {
"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.",
"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.",
"type": "string"
},
"resource_type": {
Expand Down
25 changes: 10 additions & 15 deletions codersdk/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,30 @@ 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
// 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 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 AuthorizationObject `json:"object"`
// Action can be `create`, `read`, `update`, or `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.
ResourceType string `json:"resource_type"`
// OwnerID (optional) is a user_id. It adds the set constraint to all resources owned
// by a given user.
// OwnerID (optional) adds the set constraint to all resources owned by a given user.
OwnerID string `json:"owner_id,omitempty"`
// OrganizationID (optional) is an organization_id. It adds the set constraint to
// all resources owned by a given organization.
// Organization ID (optional) adds the set constraint to all resources owned by a given organization.
OrganizationID string `json:"organization_id,omitempty"`
// ResourceID (optional) reduces the set to a singular resource. This assigns
// a resource ID to the resource type, eg: a single workspace.
// The rbac library will not fetch the resource from the database, so if you
// are using this option, you should also set the 'OwnerID' and 'OrganizationID'
// are using this option, you should also set the `OwnerID` and `OrganizationID`
// if possible. Be as specific as possible using all the fields relevant.
ResourceID string `json:"resource_id,omitempty"`
}
Expand Down
6 changes: 3 additions & 3 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@

| Name | Type | Required | Restrictions | Description |
| ----------------- | ------ | -------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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. |
| `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. |
| `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. |
| `organization_id` | string | false | none | Organization ID (optional) adds the set constraint to all resources owned by a given organization. |
| `owner_id` | string | false | none | Owner id (optional) adds the set constraint to all resources owned by a given user. |
| `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. |
| `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. |

## codersdk.AuthorizationRequest
Expand Down