diff options
Diffstat (limited to 'app/controllers/oauth2_discovery.go')
-rw-r--r-- | app/controllers/oauth2_discovery.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/controllers/oauth2_discovery.go b/app/controllers/oauth2_discovery.go new file mode 100644 index 0000000..15528e6 --- /dev/null +++ b/app/controllers/oauth2_discovery.go | |||
@@ -0,0 +1,27 @@ | |||
1 | package controllers | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | "net/http" | ||
6 | |||
7 | "code.crute.us/mcrute/ssh-proxy/app/models" | ||
8 | "github.com/labstack/echo/v4" | ||
9 | ) | ||
10 | |||
11 | type Oauth2DiscoveryController struct { | ||
12 | Hostname string | ||
13 | } | ||
14 | |||
15 | func (d *Oauth2DiscoveryController) Handle(c echo.Context) error { | ||
16 | return c.JSON(http.StatusOK, models.OauthDiscoveryMetadata{ | ||
17 | Issuer: d.Hostname, | ||
18 | AuthorizationEndpoint: fmt.Sprintf("%s/auth/login", d.Hostname), // Not really supported here | ||
19 | TokenEndpoint: fmt.Sprintf("%s/auth/token", d.Hostname), | ||
20 | DeviceAuthorizationEndpoint: fmt.Sprintf("%s/auth/device", d.Hostname), | ||
21 | SupportedResponseTypes: []string{models.ResponseTypeCode}, | ||
22 | SupportedGrantTypes: []string{models.GrantTypeDevice}, | ||
23 | SupportedResponseModes: []string{models.ResponseModeQuery}, | ||
24 | SupportedUILocales: []string{"en-us"}, | ||
25 | SupportedChallengeCodeMethods: []string{models.ChallengeTypeSHA256}, | ||
26 | }) | ||
27 | } | ||