Skip to content

Commit

Permalink
fix: update dex to work with basehref (#1278)
Browse files Browse the repository at this point in the history
Signed-off-by: jyu6 <[email protected]>
Co-authored-by: jyu6 <[email protected]>
  • Loading branch information
jy4096 and jyu6 authored Oct 26, 2023
1 parent 36610a5 commit 9325140
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/base/dex/numaflow-dex-server-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data:
staticClients:
- id: numaflow-server-app
redirectURIs:
- <HOSTNAME>/login
- <HOSTNAME>/<base_herf>/login
name: 'Numaflow Server App'
public: true
connectors:
Expand Down
11 changes: 6 additions & 5 deletions config/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16373,11 +16373,12 @@ metadata:
apiVersion: v1
data:
config.yaml: "issuer: <HOSTNAME>/dex\nstorage:\n type: memory\nweb:\n http: 0.0.0.0:5556\nstaticClients:\n
\ - id: numaflow-server-app\n redirectURIs: \n - <HOSTNAME>/login\n name:
'Numaflow Server App'\n public: true\nconnectors:\n- type: github\n # https://dexidp.io/docs/connectors/github/\n
\ id: github\n name: GitHub\n config:\n clientID: $GITHUB_CLIENT_ID\n clientSecret:
$GITHUB_CLIENT_SECRET\n redirectURI: <HOSTNAME>/dex/callback\n orgs:\n -
name: <ORG_NAME>\n teams:\n - admin\n - readonly\noauth2:\n skipApprovalScreen:
\ - id: numaflow-server-app\n redirectURIs: \n - <HOSTNAME>/<base_herf>/login\n
\ name: 'Numaflow Server App'\n public: true\nconnectors:\n- type: github\n
\ # https://dexidp.io/docs/connectors/github/\n id: github\n name: GitHub\n
\ config:\n clientID: $GITHUB_CLIENT_ID\n clientSecret: $GITHUB_CLIENT_SECRET\n
\ redirectURI: <HOSTNAME>/dex/callback\n orgs:\n - name: <ORG_NAME>\n
\ teams:\n - admin\n - readonly\noauth2:\n skipApprovalScreen:
true\n"
kind: ConfigMap
metadata:
Expand Down
11 changes: 6 additions & 5 deletions config/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16279,11 +16279,12 @@ metadata:
apiVersion: v1
data:
config.yaml: "issuer: <HOSTNAME>/dex\nstorage:\n type: memory\nweb:\n http: 0.0.0.0:5556\nstaticClients:\n
\ - id: numaflow-server-app\n redirectURIs: \n - <HOSTNAME>/login\n name:
'Numaflow Server App'\n public: true\nconnectors:\n- type: github\n # https://dexidp.io/docs/connectors/github/\n
\ id: github\n name: GitHub\n config:\n clientID: $GITHUB_CLIENT_ID\n clientSecret:
$GITHUB_CLIENT_SECRET\n redirectURI: <HOSTNAME>/dex/callback\n orgs:\n -
name: <ORG_NAME>\n teams:\n - admin\n - readonly\noauth2:\n skipApprovalScreen:
\ - id: numaflow-server-app\n redirectURIs: \n - <HOSTNAME>/<base_herf>/login\n
\ name: 'Numaflow Server App'\n public: true\nconnectors:\n- type: github\n
\ # https://dexidp.io/docs/connectors/github/\n id: github\n name: GitHub\n
\ config:\n clientID: $GITHUB_CLIENT_ID\n clientSecret: $GITHUB_CLIENT_SECRET\n
\ redirectURI: <HOSTNAME>/dex/callback\n orgs:\n - name: <ORG_NAME>\n
\ teams:\n - admin\n - readonly\noauth2:\n skipApprovalScreen:
true\n"
kind: ConfigMap
metadata:
Expand Down
4 changes: 2 additions & 2 deletions server/apis/v1/dexauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ type DexObject struct {
}

// NewDexObject returns a new DexObject.
func NewDexObject(baseURL string, proxyURL string) (*DexObject, error) {
func NewDexObject(baseURL string, baseHref string, proxyURL string) (*DexObject, error) {
issuerURL, err := url.JoinPath(baseURL, "/dex")
if err != nil {
return nil, err
}
redirectURI, err := url.JoinPath(baseURL, "/login")
redirectURI, err := url.JoinPath(baseURL, baseHref, "/login")
if err != nil {
return nil, err
}
Expand Down
4 changes: 3 additions & 1 deletion server/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ func (s *server) Start() {
DexServerAddr: s.options.DexServerAddr,
DexProxyAddr: s.options.DexProxyAddr,
ServerAddr: s.options.ServerAddr,
})
},
s.options.BaseHref,
)
router.Use(UrlRewrite(router))
server := http.Server{
Addr: fmt.Sprintf(":%d", s.options.Port),
Expand Down
4 changes: 2 additions & 2 deletions server/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ type AuthInfo struct {

var logger = logging.NewLogger().Named("server")

func Routes(r *gin.Engine, sysInfo SystemInfo, authInfo AuthInfo) {
func Routes(r *gin.Engine, sysInfo SystemInfo, authInfo AuthInfo, baseHref string) {
r.GET("/livez", func(c *gin.Context) {
c.Status(http.StatusOK)
})
dexObj, err := v1.NewDexObject(authInfo.ServerAddr, authInfo.DexProxyAddr)
dexObj, err := v1.NewDexObject(authInfo.ServerAddr, baseHref, authInfo.DexProxyAddr)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion server/routes/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestRoutes(t *testing.T) {
DisableAuth: false,
DexServerAddr: "test-dex-server-addr",
}
Routes(router, sysInfo, authInfo)
Routes(router, sysInfo, authInfo, "/")
t.Run("/404", func(t *testing.T) {
w := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "/404", nil)
Expand Down

0 comments on commit 9325140

Please sign in to comment.