Skip to content

Commit 9285425

Browse files
committed
Logout
1 parent 0dc1d2a commit 9285425

File tree

6 files changed

+200
-2
lines changed

6 files changed

+200
-2
lines changed

coderd/apidoc/docs.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,31 @@ const docTemplate = `{
20292029
}
20302030
}
20312031
},
2032+
"/users/logout": {
2033+
"post": {
2034+
"security": [
2035+
{
2036+
"CoderSessionToken": []
2037+
}
2038+
],
2039+
"produces": [
2040+
"application/json"
2041+
],
2042+
"tags": [
2043+
"Users"
2044+
],
2045+
"summary": "Log out user",
2046+
"operationId": "log-out-user",
2047+
"responses": {
2048+
"200": {
2049+
"description": "OK",
2050+
"schema": {
2051+
"$ref": "#/definitions/codersdk.Response"
2052+
}
2053+
}
2054+
}
2055+
}
2056+
},
20322057
"/users/oauth2/github/callback": {
20332058
"get": {
20342059
"security": [
@@ -2073,6 +2098,34 @@ const docTemplate = `{
20732098
}
20742099
}
20752100
},
2101+
"/users/roles": {
2102+
"get": {
2103+
"security": [
2104+
{
2105+
"CoderSessionToken": []
2106+
}
2107+
],
2108+
"produces": [
2109+
"application/json"
2110+
],
2111+
"tags": [
2112+
"Members"
2113+
],
2114+
"summary": "Get site member roles",
2115+
"operationId": "get-site-member-roles",
2116+
"responses": {
2117+
"200": {
2118+
"description": "OK",
2119+
"schema": {
2120+
"type": "array",
2121+
"items": {
2122+
"$ref": "#/definitions/codersdk.AssignableRoles"
2123+
}
2124+
}
2125+
}
2126+
}
2127+
}
2128+
},
20762129
"/users/{user}/workspace/{workspacename}": {
20772130
"get": {
20782131
"security": [

coderd/apidoc/swagger.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,27 @@
17851785
}
17861786
}
17871787
},
1788+
"/users/logout": {
1789+
"post": {
1790+
"security": [
1791+
{
1792+
"CoderSessionToken": []
1793+
}
1794+
],
1795+
"produces": ["application/json"],
1796+
"tags": ["Users"],
1797+
"summary": "Log out user",
1798+
"operationId": "log-out-user",
1799+
"responses": {
1800+
"200": {
1801+
"description": "OK",
1802+
"schema": {
1803+
"$ref": "#/definitions/codersdk.Response"
1804+
}
1805+
}
1806+
}
1807+
}
1808+
},
17881809
"/users/oauth2/github/callback": {
17891810
"get": {
17901811
"security": [
@@ -1821,6 +1842,30 @@
18211842
}
18221843
}
18231844
},
1845+
"/users/roles": {
1846+
"get": {
1847+
"security": [
1848+
{
1849+
"CoderSessionToken": []
1850+
}
1851+
],
1852+
"produces": ["application/json"],
1853+
"tags": ["Members"],
1854+
"summary": "Get site member roles",
1855+
"operationId": "get-site-member-roles",
1856+
"responses": {
1857+
"200": {
1858+
"description": "OK",
1859+
"schema": {
1860+
"type": "array",
1861+
"items": {
1862+
"$ref": "#/definitions/codersdk.AssignableRoles"
1863+
}
1864+
}
1865+
}
1866+
}
1867+
}
1868+
},
18241869
"/users/{user}/workspace/{workspacename}": {
18251870
"get": {
18261871
"security": [

coderd/roles.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import (
1111
)
1212

1313
// assignableSiteRoles returns all site wide roles that can be assigned.
14+
//
15+
// @Summary Get site member roles
16+
// @ID get-site-member-roles
17+
// @Security CoderSessionToken
18+
// @Produce json
19+
// @Tags Members
20+
// @Success 200 {array} codersdk.AssignableRoles
21+
// @Router /users/roles [get]
1422
func (api *API) assignableSiteRoles(rw http.ResponseWriter, r *http.Request) {
1523
ctx := r.Context()
1624
actorRoles := httpmw.UserAuthorization(r)
@@ -23,6 +31,8 @@ func (api *API) assignableSiteRoles(rw http.ResponseWriter, r *http.Request) {
2331
httpapi.Write(ctx, rw, http.StatusOK, assignableRoles(actorRoles.Roles, roles))
2432
}
2533

34+
// assignableSiteRoles returns all org wide roles that can be assigned.
35+
//
2636
// @Summary Get member roles by organization
2737
// @ID get-member-roles-by-organization
2838
// @Security CoderSessionToken
@@ -31,8 +41,6 @@ func (api *API) assignableSiteRoles(rw http.ResponseWriter, r *http.Request) {
3141
// @Param organization path string true "Organization ID" format(uuid)
3242
// @Success 200 {array} codersdk.AssignableRoles
3343
// @Router /organizations/{organization}/members/roles [get]
34-
//
35-
// assignableSiteRoles returns all site wide roles that can be assigned.
3644
func (api *API) assignableOrgRoles(rw http.ResponseWriter, r *http.Request) {
3745
ctx := r.Context()
3846
organization := httpmw.OrganizationParam(r)

coderd/users.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,14 @@ func (api *API) postLogin(rw http.ResponseWriter, r *http.Request) {
970970
}
971971

972972
// Clear the user's session cookie.
973+
//
974+
// @Summary Log out user
975+
// @ID log-out-user
976+
// @Security CoderSessionToken
977+
// @Produce json
978+
// @Tags Users
979+
// @Success 200 {object} codersdk.Response
980+
// @Router /users/logout [post]
973981
func (api *API) postLogout(rw http.ResponseWriter, r *http.Request) {
974982
ctx := r.Context()
975983
// Get a blank token cookie.

docs/api/members.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,49 @@ curl -X PUT http://coder-server:8080/api/v2/organizations/{organization}/members
110110
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.OrganizationMember](schemas.md#codersdkorganizationmember) |
111111

112112
To perform this operation, you must be authenticated. [Learn more](authentication.md).
113+
114+
## Get site member roles
115+
116+
### Code samples
117+
118+
```shell
119+
# Example request using curl
120+
curl -X GET http://coder-server:8080/api/v2/users/roles \
121+
-H 'Accept: application/json' \
122+
-H 'Coder-Session-Token: API_KEY'
123+
```
124+
125+
`GET /users/roles`
126+
127+
### Example responses
128+
129+
> 200 Response
130+
131+
```json
132+
[
133+
{
134+
"assignable": true,
135+
"display_name": "string",
136+
"name": "string"
137+
}
138+
]
139+
```
140+
141+
### Responses
142+
143+
| Status | Meaning | Description | Schema |
144+
| ------ | ------------------------------------------------------- | ----------- | ----------------------------------------------------------------------- |
145+
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | array of [codersdk.AssignableRoles](schemas.md#codersdkassignableroles) |
146+
147+
<h3 id="get-site-member-roles-responseschema">Response Schema</h3>
148+
149+
Status Code **200**
150+
151+
| Name | Type | Required | Restrictions | Description |
152+
| ---------------- | ------- | -------- | ------------ | ----------- |
153+
| `[array item]` | array | false | | |
154+
| `» assignable` | boolean | false | | |
155+
| `» display_name` | string | false | | |
156+
| `» name` | string | false | | |
157+
158+
To perform this operation, you must be authenticated. [Learn more](authentication.md).

docs/api/users.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,44 @@ curl -X POST http://coder-server:8080/api/v2/users/first \
243243

244244
To perform this operation, you must be authenticated. [Learn more](authentication.md).
245245

246+
## Log out user
247+
248+
### Code samples
249+
250+
```shell
251+
# Example request using curl
252+
curl -X POST http://coder-server:8080/api/v2/users/logout \
253+
-H 'Accept: application/json' \
254+
-H 'Coder-Session-Token: API_KEY'
255+
```
256+
257+
`POST /users/logout`
258+
259+
### Example responses
260+
261+
> 200 Response
262+
263+
```json
264+
{
265+
"detail": "string",
266+
"message": "string",
267+
"validations": [
268+
{
269+
"detail": "string",
270+
"field": "string"
271+
}
272+
]
273+
}
274+
```
275+
276+
### Responses
277+
278+
| Status | Meaning | Description | Schema |
279+
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------ |
280+
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.Response](schemas.md#codersdkresponse) |
281+
282+
To perform this operation, you must be authenticated. [Learn more](authentication.md).
283+
246284
## OAuth 2.0 GitHub Callback
247285

248286
### Code samples

0 commit comments

Comments
 (0)