mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
feat: add endpoints to oauth2 provider applications (#11718)
These will show up when configuring the application along with the client ID and everything else. Should make it easier to configure the application, otherwise you will have to go look up the URLs in the docs (which are not yet written). Co-authored-by: Steven Masley <stevenmasley@gmail.com>
This commit is contained in:
23
coderd/apidoc/docs.go
generated
23
coderd/apidoc/docs.go
generated
@ -9688,6 +9688,21 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.OAuth2AppEndpoints": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"authorization": {
|
||||
"type": "string"
|
||||
},
|
||||
"device_authorization": {
|
||||
"description": "DeviceAuth is optional.",
|
||||
"type": "string"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.OAuth2Config": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -9734,6 +9749,14 @@ const docTemplate = `{
|
||||
"callback_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"endpoints": {
|
||||
"description": "Endpoints are included in the app response for easier discovery. The OAuth2\nspec does not have a defined place to find these (for comparison, OIDC has\na '/.well-known/openid-configuration' endpoint).",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/codersdk.OAuth2AppEndpoints"
|
||||
}
|
||||
]
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
},
|
||||
|
23
coderd/apidoc/swagger.json
generated
23
coderd/apidoc/swagger.json
generated
@ -8683,6 +8683,21 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.OAuth2AppEndpoints": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"authorization": {
|
||||
"type": "string"
|
||||
},
|
||||
"device_authorization": {
|
||||
"description": "DeviceAuth is optional.",
|
||||
"type": "string"
|
||||
},
|
||||
"token": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.OAuth2Config": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -8729,6 +8744,14 @@
|
||||
"callback_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"endpoints": {
|
||||
"description": "Endpoints are included in the app response for easier discovery. The OAuth2\nspec does not have a defined place to find these (for comparison, OIDC has\na '/.well-known/openid-configuration' endpoint).",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/codersdk.OAuth2AppEndpoints"
|
||||
}
|
||||
]
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -4,6 +4,7 @@ package db2sdk
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -226,19 +227,29 @@ func templateVersionParameterOptions(rawOptions json.RawMessage) ([]codersdk.Tem
|
||||
return options, nil
|
||||
}
|
||||
|
||||
func OAuth2ProviderApp(dbApp database.OAuth2ProviderApp) codersdk.OAuth2ProviderApp {
|
||||
func OAuth2ProviderApp(accessURL *url.URL, dbApp database.OAuth2ProviderApp) codersdk.OAuth2ProviderApp {
|
||||
return codersdk.OAuth2ProviderApp{
|
||||
ID: dbApp.ID,
|
||||
Name: dbApp.Name,
|
||||
CallbackURL: dbApp.CallbackURL,
|
||||
Icon: dbApp.Icon,
|
||||
Endpoints: codersdk.OAuth2AppEndpoints{
|
||||
Authorization: accessURL.ResolveReference(&url.URL{
|
||||
Path: "/login/oauth2/authorize",
|
||||
}).String(),
|
||||
Token: accessURL.ResolveReference(&url.URL{
|
||||
Path: "/login/oauth2/tokens",
|
||||
}).String(),
|
||||
// We do not currently support DeviceAuth.
|
||||
DeviceAuth: "",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func OAuth2ProviderApps(dbApps []database.OAuth2ProviderApp) []codersdk.OAuth2ProviderApp {
|
||||
func OAuth2ProviderApps(accessURL *url.URL, dbApps []database.OAuth2ProviderApp) []codersdk.OAuth2ProviderApp {
|
||||
apps := []codersdk.OAuth2ProviderApp{}
|
||||
for _, dbApp := range dbApps {
|
||||
apps = append(apps, OAuth2ProviderApp(dbApp))
|
||||
apps = append(apps, OAuth2ProviderApp(accessURL, dbApp))
|
||||
}
|
||||
return apps
|
||||
}
|
||||
|
Reference in New Issue
Block a user