Handle next parameters even through OIDC
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a3e1797240
commit
5e20cec59d
14
auth_oidc.go
14
auth_oidc.go
@ -20,6 +20,7 @@ var (
|
||||
oidcRedirectURL = "https://srs.nemunai.re"
|
||||
oauth2Config oauth2.Config
|
||||
oidcVerifier *oidc.IDTokenVerifier
|
||||
nextSessionMap = map[string]string{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -60,6 +61,12 @@ func initializeOIDC() {
|
||||
|
||||
func redirectOIDC_CRI(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
session, err := NewSession()
|
||||
|
||||
// Save next parameter
|
||||
if len(r.URL.Query().Get("next")) > 0 {
|
||||
nextSessionMap[fmt.Sprintf("%x", session.Id)] = r.URL.Query().Get("next")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("{'errmsg':%q}", err.Error()), http.StatusInternalServerError)
|
||||
} else {
|
||||
@ -121,5 +128,12 @@ func OIDC_CRI_complete(w http.ResponseWriter, r *http.Request, ps httprouter.Par
|
||||
return
|
||||
}
|
||||
|
||||
// Retrieve next URL associated with session
|
||||
if next, ok := nextSessionMap[fmt.Sprintf("%x", session.Id)]; ok {
|
||||
http.Redirect(w, r, next, http.StatusFound)
|
||||
delete(nextSessionMap, fmt.Sprintf("%x", session.Id))
|
||||
} else {
|
||||
http.Redirect(w, r, "/", http.StatusFound)
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user