@@ -353,23 +353,34 @@ func TemplateVersionParameterOptionFromPreview(option *previewtypes.ParameterOpt
353
353
}
354
354
}
355
355
356
+ // oauth2AppEndpoints generates the OAuth2 endpoints for an app
357
+ func oauth2AppEndpoints (accessURL * url.URL ) codersdk.OAuth2AppEndpoints {
358
+ return codersdk.OAuth2AppEndpoints {
359
+ Authorization : accessURL .ResolveReference (& url.URL {
360
+ Path : "/oauth2/authorize" ,
361
+ }).String (),
362
+ Token : accessURL .ResolveReference (& url.URL {
363
+ Path : "/oauth2/token" ,
364
+ }).String (),
365
+ DeviceAuth : accessURL .ResolveReference (& url.URL {
366
+ Path : "/oauth2/device" ,
367
+ }).String (),
368
+ Revocation : accessURL .ResolveReference (& url.URL {
369
+ Path : "/oauth2/revoke" ,
370
+ }).String (),
371
+ }
372
+ }
373
+
356
374
func OAuth2ProviderApp (accessURL * url.URL , dbApp database.OAuth2ProviderApp ) codersdk.OAuth2ProviderApp {
357
375
return codersdk.OAuth2ProviderApp {
358
376
ID : dbApp .ID ,
359
377
Name : dbApp .Name ,
360
378
RedirectURIs : dbApp .RedirectUris ,
361
379
Icon : dbApp .Icon ,
362
- Endpoints : codersdk.OAuth2AppEndpoints {
363
- Authorization : accessURL .ResolveReference (& url.URL {
364
- Path : "/oauth2/authorize" ,
365
- }).String (),
366
- Token : accessURL .ResolveReference (& url.URL {
367
- Path : "/oauth2/token" ,
368
- }).String (),
369
- DeviceAuth : accessURL .ResolveReference (& url.URL {
370
- Path : "/oauth2/device/authorize" ,
371
- }).String (),
372
- },
380
+ CreatedAt : dbApp .CreatedAt ,
381
+ GrantTypes : dbApp .GrantTypes ,
382
+ UserID : dbApp .UserID .UUID ,
383
+ Endpoints : oauth2AppEndpoints (accessURL ),
373
384
}
374
385
}
375
386
@@ -379,6 +390,55 @@ func OAuth2ProviderApps(accessURL *url.URL, dbApps []database.OAuth2ProviderApp)
379
390
})
380
391
}
381
392
393
+ func OAuth2ProviderAppRow (accessURL * url.URL , dbApp database.GetOAuth2ProviderAppByIDRow ) codersdk.OAuth2ProviderApp {
394
+ return codersdk.OAuth2ProviderApp {
395
+ ID : dbApp .ID ,
396
+ Name : dbApp .Name ,
397
+ RedirectURIs : dbApp .RedirectUris ,
398
+ Icon : dbApp .Icon ,
399
+ CreatedAt : dbApp .CreatedAt ,
400
+ GrantTypes : dbApp .GrantTypes ,
401
+ UserID : dbApp .UserID .UUID ,
402
+ Username : dbApp .Username .String ,
403
+ Email : dbApp .Email .String ,
404
+ Endpoints : oauth2AppEndpoints (accessURL ),
405
+ }
406
+ }
407
+
408
+ func OAuth2ProviderAppsRows (accessURL * url.URL , dbApps []database.GetOAuth2ProviderAppsRow ) []codersdk.OAuth2ProviderApp {
409
+ return List (dbApps , func (dbApp database.GetOAuth2ProviderAppsRow ) codersdk.OAuth2ProviderApp {
410
+ return codersdk.OAuth2ProviderApp {
411
+ ID : dbApp .ID ,
412
+ Name : dbApp .Name ,
413
+ RedirectURIs : dbApp .RedirectUris ,
414
+ Icon : dbApp .Icon ,
415
+ CreatedAt : dbApp .CreatedAt ,
416
+ GrantTypes : dbApp .GrantTypes ,
417
+ UserID : dbApp .UserID .UUID ,
418
+ Username : dbApp .Username .String ,
419
+ Email : dbApp .Email .String ,
420
+ Endpoints : oauth2AppEndpoints (accessURL ),
421
+ }
422
+ })
423
+ }
424
+
425
+ func OAuth2ProviderAppsByOwnerIDRows (accessURL * url.URL , dbApps []database.GetOAuth2ProviderAppsByOwnerIDRow ) []codersdk.OAuth2ProviderApp {
426
+ return List (dbApps , func (dbApp database.GetOAuth2ProviderAppsByOwnerIDRow ) codersdk.OAuth2ProviderApp {
427
+ return codersdk.OAuth2ProviderApp {
428
+ ID : dbApp .ID ,
429
+ Name : dbApp .Name ,
430
+ RedirectURIs : dbApp .RedirectUris ,
431
+ Icon : dbApp .Icon ,
432
+ CreatedAt : dbApp .CreatedAt ,
433
+ GrantTypes : dbApp .GrantTypes ,
434
+ UserID : dbApp .UserID .UUID ,
435
+ Username : dbApp .Username .String ,
436
+ Email : dbApp .Email .String ,
437
+ Endpoints : oauth2AppEndpoints (accessURL ),
438
+ }
439
+ })
440
+ }
441
+
382
442
func convertDisplayApps (apps []database.DisplayApp ) []codersdk.DisplayApp {
383
443
dapps := make ([]codersdk.DisplayApp , 0 , len (apps ))
384
444
for _ , app := range apps {
0 commit comments