Skip to content
Snippets Groups Projects
Unverified Commit d8d8c2f6 authored by Bruno Michel's avatar Bruno Michel Committed by GitHub
Browse files

Allow to redirect to an app for OIDC onboarding (#3044)

A Cozy can be onboarded with the need to redirect to a specific app.
The password selection page accepts a redirection parameter for this
use case, but when the OIDC method is used for authentication, the user
doesn't go on this page and it doesn't work. We now accept also this
redirection parameter for / when OIDC is enabled.
parent a074e8be
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/cozy/cozy-stack/model/app"
"github.com/cozy/cozy-stack/model/bitwarden/settings" "github.com/cozy/cozy-stack/model/bitwarden/settings"
"github.com/cozy/cozy-stack/model/instance" "github.com/cozy/cozy-stack/model/instance"
"github.com/cozy/cozy-stack/model/instance/lifecycle" "github.com/cozy/cozy-stack/model/instance/lifecycle"
...@@ -74,6 +75,24 @@ func Home(c echo.Context) error { ...@@ -74,6 +75,24 @@ func Home(c echo.Context) error {
return c.Redirect(http.StatusSeeOther, redirect.String()) return c.Redirect(http.StatusSeeOther, redirect.String())
} }
// Onboarding to a specific app when authentication via OIDC is enabled
redirection := c.QueryParam("redirection")
if redirection != "" && !instance.IsPasswordAuthenticationEnabled() {
splits := strings.SplitN(redirection, "#", 2)
parts := strings.SplitN(splits[0], "/", 2)
if _, err := app.GetWebappBySlug(instance, parts[0]); err == nil {
u := instance.SubDomain(parts[0])
if len(parts) == 2 {
u.Path = parts[1]
}
if len(splits) == 2 {
u.Fragment = splits[1]
}
q := url.Values{"redirect": {u.String()}}
return c.Redirect(http.StatusSeeOther, instance.PageURL("/oidc/start", q))
}
}
var params url.Values var params url.Values
if jwt := c.QueryParam("jwt"); jwt != "" { if jwt := c.QueryParam("jwt"); jwt != "" {
params = url.Values{"jwt": {jwt}} params = url.Values{"jwt": {jwt}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment