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
Next Next commit
docs: Applications
  • Loading branch information
mtojek committed Dec 20, 2022
commit ffc17487c6934ef077273668d3b9092924ce31c5
64 changes: 64 additions & 0 deletions coderd/apidoc/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,61 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/applications/auth-redirect": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Applications"
],
"summary": "Redirect to URI with encrypted API key",
"operationId": "redirect-to-uri-with-encrypted-api-key",
"parameters": [
{
"type": "string",
"description": "Redirect destination",
"name": "redirect_uri",
"in": "query"
}
],
"responses": {
"307": {
"description": "Temporary Redirect"
}
}
}
},
"/applications/host": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": [
"application/json"
],
"tags": [
"Applications"
],
"summary": "Get applications host",
"operationId": "get-app-host",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.GetAppHostResponse"
}
}
}
}
},
"/organizations/{organization-id}/templates/": {
"post": {
"security": [
Expand Down Expand Up @@ -712,6 +767,15 @@ const docTemplate = `{
}
}
},
"codersdk.GetAppHostResponse": {
"type": "object",
"properties": {
"host": {
"description": "Host is the externally accessible URL for the Coder instance.",
"type": "string"
}
}
},
"codersdk.Healthcheck": {
"type": "object",
"properties": {
Expand Down
56 changes: 56 additions & 0 deletions coderd/apidoc/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,53 @@
},
"basePath": "/api/v2",
"paths": {
"/applications/auth-redirect": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Applications"],
"summary": "Redirect to URI with encrypted API key",
"operationId": "redirect-to-uri-with-encrypted-api-key",
"parameters": [
{
"type": "string",
"description": "Redirect destination",
"name": "redirect_uri",
"in": "query"
}
],
"responses": {
"307": {
"description": "Temporary Redirect"
}
}
}
},
"/applications/host": {
"get": {
"security": [
{
"CoderSessionToken": []
}
],
"produces": ["application/json"],
"tags": ["Applications"],
"summary": "Get applications host",
"operationId": "get-app-host",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/codersdk.GetAppHostResponse"
}
}
}
}
},
"/organizations/{organization-id}/templates/": {
"post": {
"security": [
Expand Down Expand Up @@ -635,6 +682,15 @@
}
}
},
"codersdk.GetAppHostResponse": {
"type": "object",
"properties": {
"host": {
"description": "Host is the externally accessible URL for the Coder instance.",
"type": "string"
}
}
},
"codersdk.Healthcheck": {
"type": "object",
"properties": {
Expand Down
16 changes: 16 additions & 0 deletions coderd/workspaceapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ var nonCanonicalHeaders = map[string]string{
"Sec-Websocket-Version": "Sec-WebSocket-Version",
}

// @Summary Get applications host
// @ID get-app-host
// @Security CoderSessionToken
// @Produce json
// @Tags Applications
// @Success 200 {object} codersdk.GetAppHostResponse
// @Router /applications/host [get]
func (api *API) appHost(rw http.ResponseWriter, r *http.Request) {
host := api.AppHostname
if host != "" && api.AccessURL.Port() != "" {
Expand Down Expand Up @@ -484,6 +491,15 @@ func (api *API) verifyWorkspaceApplicationSubdomainAuth(rw http.ResponseWriter,
return false
}

// @Summary Redirect to URI with encrypted API key
// @ID redirect-to-uri-with-encrypted-api-key
// @Security CoderSessionToken
// @Produce json
// @Tags Applications
// @Param redirect_uri query string false "Redirect destination"
// @Success 307
// @Router /applications/auth-redirect [get]
//
// workspaceApplicationAuth is an endpoint on the main router that handles
// redirects from the subdomain handler.
//
Expand Down
1 change: 1 addition & 0 deletions codersdk/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ func (c *Client) WorkspaceByOwnerAndName(ctx context.Context, owner string, name
}

type GetAppHostResponse struct {
// Host is the externally accessible URL for the Coder instance.
Host string `json:"host"`
}

Expand Down
62 changes: 62 additions & 0 deletions docs/api/applications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Applications

> This page is incomplete, stay tuned.

## Redirect to URI with encrypted API key

### Code samples

```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/applications/auth-redirect \
-H 'Coder-Session-Token: API_KEY'

```

`GET /applications/auth-redirect`

### Parameters

| Name | In | Type | Required | Description |
| ------------ | ----- | ------ | -------- | -------------------- |
| redirect_uri | query | string | false | Redirect destination |

### Responses

| Status | Meaning | Description | Schema |
| ------ | ----------------------------------------------------------------------- | ------------------ | --------- |
| 307 | [Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7) | Temporary Redirect | no schema |

To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.

## Get applications host

### Code samples

```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/applications/host \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'

```

`GET /applications/host`

### Example responses

> 200 Response

```json
{
"host": "string"
}
```

### Responses

| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | -------------------------------------------------------------------- |
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.GetAppHostResponse](schemas.md#codersdkgetapphostresponse) |

To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.
14 changes: 14 additions & 0 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@
| `latency_ms` | number | false | none | none |
| `preferred` | boolean | false | none | none |

## codersdk.GetAppHostResponse

```json
{
"host": "string"
}
```

### Properties

| Name | Type | Required | Restrictions | Description |
| ------ | ------ | -------- | ------------ | ------------------------------------------------------------- |
| `host` | string | false | none | Host is the externally accessible URL for the Coder instance. |

## codersdk.Healthcheck

```json
Expand Down
4 changes: 4 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@
"title": "Authentication",
"path": "./api/authentication.md"
},
{
"title": "Applications",
"path": "./api/applications.md"
},
{
"title": "Templates",
"path": "./api/templates.md"
Expand Down