Skip to content

Commit

Permalink
draft: serve wellknown openid configuration from metadata server
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyzimmer committed Oct 19, 2023
1 parent e9edc09 commit a4fe8ee
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 45 deletions.
1 change: 1 addition & 0 deletions examples/webmesh-desktop/deploy/allowed-ids.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# An example of pre-allowed IDs that we want to give
# access to our applications and the network at large.
apiVersion: v1
Expand Down
10 changes: 10 additions & 0 deletions examples/webmesh-desktop/deploy/app-secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# Dummy OIDC client credentials for the Webmesh Desktop.
apiVersion: v1
kind: Secret
metadata:
name: kvdi-app-secrets
namespace: default
stringData:
oidc-clientid: "kvdi"
oidc-clientsecret: "kvdi"
1 change: 1 addition & 0 deletions examples/webmesh-desktop/deploy/desktop-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ vdi:
spec:
app:
image: ghcr.io/webmeshproj/vdi-app:latest
serviceType: ClusterIP
auth:
tokenDuration: 8h
oidcAuth:
Expand Down
45 changes: 0 additions & 45 deletions examples/webmesh-desktop/deploy/example-app.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions internal/metadata/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,26 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
switch r.URL.Path {
case "/.well-known/openid-configuration":
if !s.EnableOauth {
s.returnError(w, fmt.Errorf("oauth is not enabled"))
return
}
// We return the oauth endpoints.
rlog.Info("Serving oauth endpoints")
info := map[string]any{
"authorization_endpoint": fmt.Sprintf("http://%s/authorize", s.Address.String()),
"token_endpoint": fmt.Sprintf("http://%s/token", s.Address.String()),
"userinfo_endpoint": fmt.Sprintf("http://%s/userinfo", s.Address.String()),
"jwks_uri": fmt.Sprintf("http://%s/jwks", s.Address.String()),
"scopes_supported": []string{"openid", "profile"},
}
out, err := json.MarshalIndent(info, "", " ")
if err != nil {
s.returnError(w, err)
return
}
fmt.Fprintln(w, string(out))
case "/":
// We return the available keys for the metadata server.
// This is a bit of a hack but we marshal the peer to JSON
Expand Down

0 comments on commit a4fe8ee

Please sign in to comment.