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:
@ -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