Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite413c6c

Browse files
committed
wip: endpoints, remove after rebase
1 parentdd339ea commite413c6c

File tree

10 files changed

+188
-33
lines changed

10 files changed

+188
-33
lines changed

‎coderd/apidoc/docs.go

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/db2sdk/db2sdk.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package db2sdk
44
import (
55
"encoding/json"
66
"fmt"
7+
"net/url"
78
"strconv"
89
"strings"
910
"time"
@@ -226,19 +227,29 @@ func templateVersionParameterOptions(rawOptions json.RawMessage) ([]codersdk.Tem
226227
returnoptions,nil
227228
}
228229

229-
funcOAuth2ProviderApp(dbApp database.OAuth2ProviderApp) codersdk.OAuth2ProviderApp {
230+
funcOAuth2ProviderApp(accessURL*url.URL,dbApp database.OAuth2ProviderApp) codersdk.OAuth2ProviderApp {
230231
return codersdk.OAuth2ProviderApp{
231232
ID:dbApp.ID,
232233
Name:dbApp.Name,
233234
CallbackURL:dbApp.CallbackURL,
234235
Icon:dbApp.Icon,
236+
Endpoints: codersdk.OAuth2AppEndpoints{
237+
Authorization:accessURL.ResolveReference(&url.URL{
238+
Path:"/login/oauth2/authorize",
239+
}).String(),
240+
Token:accessURL.ResolveReference(&url.URL{
241+
Path:"/login/oauth2/tokens",
242+
}).String(),
243+
// We do not currently support DeviceAuth.
244+
DeviceAuth:"",
245+
},
235246
}
236247
}
237248

238-
funcOAuth2ProviderApps(dbApps []database.OAuth2ProviderApp) []codersdk.OAuth2ProviderApp {
249+
funcOAuth2ProviderApps(accessURL*url.URL,dbApps []database.OAuth2ProviderApp) []codersdk.OAuth2ProviderApp {
239250
apps:= []codersdk.OAuth2ProviderApp{}
240251
for_,dbApp:=rangedbApps {
241-
apps=append(apps,OAuth2ProviderApp(dbApp))
252+
apps=append(apps,OAuth2ProviderApp(accessURL,dbApp))
242253
}
243254
returnapps
244255
}

‎codersdk/oauth2.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ type OAuth2ProviderApp struct {
1414
Namestring`json:"name"`
1515
CallbackURLstring`json:"callback_url"`
1616
Iconstring`json:"icon"`
17+
18+
// Endpoints are included in the app response for easier discovery. The OAuth2
19+
// spec does not have a defined place to find these (for comparison, OIDC has
20+
// a '/.well-known/openid-configuration' endpoint).
21+
EndpointsOAuth2AppEndpoints`json:"endpoints"`
22+
}
23+
24+
typeOAuth2AppEndpointsstruct {
25+
Authorizationstring`json:"authorization"`
26+
Tokenstring`json:"token"`
27+
// DeviceAuth is optional.
28+
DeviceAuthstring`json:"device_authorization"`
1729
}
1830

1931
typeOAuth2ProviderAppFilterstruct {

‎docs/api/enterprise.md

Lines changed: 31 additions & 7 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/api/schemas.md

Lines changed: 30 additions & 6 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎enterprise/coderd/oauth2.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (api *API) oAuth2ProviderApps(rw http.ResponseWriter, r *http.Request) {
6262
httpapi.InternalServerError(rw,err)
6363
return
6464
}
65-
httpapi.Write(ctx,rw,http.StatusOK,db2sdk.OAuth2ProviderApps(dbApps))
65+
httpapi.Write(ctx,rw,http.StatusOK,db2sdk.OAuth2ProviderApps(api.AccessURL,dbApps))
6666
return
6767
}
6868

@@ -90,7 +90,7 @@ func (api *API) oAuth2ProviderApps(rw http.ResponseWriter, r *http.Request) {
9090
Icon:app.OAuth2ProviderApp.Icon,
9191
})
9292
}
93-
httpapi.Write(ctx,rw,http.StatusOK,db2sdk.OAuth2ProviderApps(dbApps))
93+
httpapi.Write(ctx,rw,http.StatusOK,db2sdk.OAuth2ProviderApps(api.AccessURL,dbApps))
9494
}
9595

9696
// @Summary Get OAuth2 application.
@@ -101,10 +101,10 @@ func (api *API) oAuth2ProviderApps(rw http.ResponseWriter, r *http.Request) {
101101
// @Param app path string true "App ID"
102102
// @Success 200 {object} codersdk.OAuth2ProviderApp
103103
// @Router /oauth2-provider/apps/{app} [get]
104-
func (*API)oAuth2ProviderApp(rw http.ResponseWriter,r*http.Request) {
104+
func (api*API)oAuth2ProviderApp(rw http.ResponseWriter,r*http.Request) {
105105
ctx:=r.Context()
106106
app:=httpmw.OAuth2ProviderApp(r)
107-
httpapi.Write(ctx,rw,http.StatusOK,db2sdk.OAuth2ProviderApp(app))
107+
httpapi.Write(ctx,rw,http.StatusOK,db2sdk.OAuth2ProviderApp(api.AccessURL,app))
108108
}
109109

110110
// @Summary Create OAuth2 application.
@@ -137,7 +137,7 @@ func (api *API) postOAuth2ProviderApp(rw http.ResponseWriter, r *http.Request) {
137137
})
138138
return
139139
}
140-
httpapi.Write(ctx,rw,http.StatusCreated,db2sdk.OAuth2ProviderApp(app))
140+
httpapi.Write(ctx,rw,http.StatusCreated,db2sdk.OAuth2ProviderApp(api.AccessURL,app))
141141
}
142142

143143
// @Summary Update OAuth2 application.
@@ -171,7 +171,7 @@ func (api *API) putOAuth2ProviderApp(rw http.ResponseWriter, r *http.Request) {
171171
})
172172
return
173173
}
174-
httpapi.Write(ctx,rw,http.StatusOK,db2sdk.OAuth2ProviderApp(app))
174+
httpapi.Write(ctx,rw,http.StatusOK,db2sdk.OAuth2ProviderApp(api.AccessURL,app))
175175
}
176176

177177
// @Summary Delete OAuth2 application.

‎site/src/api/typesGenerated.ts

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/pages/DeploySettingsPage/OAuth2AppsSettingsPage/EditOAuth2AppPageView.tsx

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{useTheme}from"@emotion/react";
1+
import{typeInterpolation,typeTheme,useTheme}from"@emotion/react";
22
importCopyIconfrom"@mui/icons-material/FileCopyOutlined";
33
importKeyboardArrowLeftfrom"@mui/icons-material/KeyboardArrowLeft";
44
importDividerfrom"@mui/material/Divider";
@@ -139,16 +139,28 @@ export const EditOAuth2AppPageView: FC<EditOAuth2AppProps> = ({
139139
onCancel={()=>setShowDelete(false)}
140140
/>
141141

142-
<h2css={{marginBottom:0}}>Client ID</h2>
143-
<CopyableValuevalue={app.id}>
144-
{app.id}{" "}
145-
<CopyIcon
146-
css={{
147-
width:16,
148-
height:16,
149-
}}
150-
/>
151-
</CopyableValue>
142+
<dlcss={styles.dataList}>
143+
<dt>Client ID</dt>
144+
<dd>
145+
<CopyableValuevalue={app.id}>
146+
{app.id}<CopyIconcss={{width:16,height:16}}/>
147+
</CopyableValue>
148+
</dd>
149+
<dt>Authorization URL</dt>
150+
<dd>
151+
<CopyableValuevalue={app.endpoints.authorization}>
152+
{app.endpoints.authorization}{" "}
153+
<CopyIconcss={{width:16,height:16}}/>
154+
</CopyableValue>
155+
</dd>
156+
<dt>Token URL</dt>
157+
<dd>
158+
<CopyableValuevalue={app.endpoints.token}>
159+
{app.endpoints.token}{" "}
160+
<CopyIconcss={{width:16,height:16}}/>
161+
</CopyableValue>
162+
</dd>
163+
</dl>
152164

153165
<Dividercss={{borderColor:theme.palette.divider}}/>
154166

@@ -303,3 +315,16 @@ const OAuth2SecretRow: FC<OAuth2SecretRowProps> = ({
303315
</TableRow>
304316
);
305317
};
318+
319+
conststyles={
320+
dataList:{
321+
display:"grid",
322+
gridTemplateColumns:"max-content auto",
323+
"& > dt":{
324+
fontWeight:"bold",
325+
},
326+
"& > dd":{
327+
marginLeft:10,
328+
},
329+
},
330+
}satisfiesRecord<string,Interpolation<Theme>>;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp