Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add keycloak redirect #683

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/revproxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type renkuServicesConfig struct {
CoreServiceNames []string `mapstructure:"renku_services_core_service_names"`
CoreServicePaths []string `mapstructure:"renku_services_core_service_paths"`
Auth *url.URL `mapstructure:"renku_services_auth"`
DataService *url.URL `mapstructure:"renku_services_data_service"`
DataService *url.URL `mapstructure:"renku_services_data_service"`
Keycloak *url.URL `mapstructure:"renku_services_keycloak"`
}

type metricsConfig struct {
Expand Down
4 changes: 4 additions & 0 deletions cmd/revproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func setupServer(ctx context.Context, config revProxyConfig) *echo.Echo {
authSvcProxy := proxyFromURL(config.RenkuServices.Auth)
kgProxy := proxyFromURL(config.RenkuServices.KG)
webhookProxy := proxyFromURL(config.RenkuServices.Webhook)
keycloakProxy := proxyFromURL(config.RenkuServices.Keycloak)
keycloakProxyHost := setHost(config.RenkuServices.Keycloak.Host)
dataServiceProxy := proxyFromURL(config.RenkuServices.DataService)
logger := middleware.Logger()

Expand Down Expand Up @@ -68,6 +70,8 @@ func setupServer(ctx context.Context, config revProxyConfig) *echo.Echo {
e.Group("/api/datasets", logger, noCookies, regexRewrite("^/api(.*)", "/knowledge-graph$1"), kgProxy)
e.Group("/api/kg", logger, gitlabAuth, noCookies, regexRewrite("^/api/kg(.*)", "/knowledge-graph$1"), kgProxy)
e.Group("/api/data", logger, dataAuth, noCookies, dataServiceProxy)
// /api/kc is used only by the ui and no one else, will be removed when the gateway is in charge of user sessions
e.Group("/api/kc", logger, stripPrefix("/api/kc"), keycloakProxyHost, keycloakProxy)

registerCoreSvcProxies(ctx, e, config, logger, checkCoreServiceMetadataVersion(config.RenkuServices.CoreServicePaths), renkuAuth, noCookies, regexRewrite(`^/api/renku(?:/\d+)?((/|\?).*)??$`, "/renku$1"))

Expand Down
7 changes: 6 additions & 1 deletion cmd/revproxy/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ func setupTestRevproxy(ctx context.Context, upstreamServerURL *url.URL, upstream
KG: upstreamServerURL,
Webhook: upstreamServerURL,
Auth: authURL,
DataService: upstreamServerURL,
DataService: upstreamServerURL,
Keycloak: upstreamServerURL,
},
Debug: true,
}
Expand Down Expand Up @@ -417,6 +418,10 @@ func TestInternalSvcRoutes(t *testing.T) {
QueryParams: map[string]string{"test1": "value1", "test2": "value2"},
Expected: TestResults{Path: "/projects/123456/webhooks", VisitedServerIDs: []string{"auth", "upstream"}},
},
{
Path: "/api/kc/auth/realms/Renku/protocol/openid-connect/userinfo",
Expected: TestResults{Path: "/auth/realms/Renku/protocol/openid-connect/userinfo", VisitedServerIDs: []string{"upstream"}},
},
}
for _, testCase := range testCases {
// Test names show up poorly in vscode if the name contains "/"
Expand Down
Loading