Skip to content
Snippets Groups Projects
Verified Commit 5e79d452 authored by Gabriel Zachmann's avatar Gabriel Zachmann
Browse files

add application name to native redirect

parent 753d07af
Branches
Tags
No related merge requests found
...@@ -83,6 +83,9 @@ func handleConsentDecline(ctx *fiber.Ctx, authInfo *authcodeinforepo.AuthFlowInf ...@@ -83,6 +83,9 @@ func handleConsentDecline(ctx *fiber.Ctx, authInfo *authcodeinforepo.AuthFlowInf
url := "/" url := "/"
if authInfo.PollingCode { if authInfo.PollingCode {
url = "/native/abort" url = "/native/abort"
if authInfo.ApplicationName != "" {
url = fmt.Sprintf("%s?application=%s", url, authInfo.ApplicationName)
}
} }
if err := authcodeinforepo.DeleteAuthFlowInfoByState(rlog, nil, oState); err != nil { if err := authcodeinforepo.DeleteAuthFlowInfoByState(rlog, nil, oState); err != nil {
rlog.Errorf("%s", errorfmt.Full(err)) rlog.Errorf("%s", errorfmt.Full(err))
......
...@@ -2,6 +2,7 @@ package authcode ...@@ -2,6 +2,7 @@ package authcode
import ( import (
"database/sql" "database/sql"
"fmt"
"strings" "strings"
"github.com/coreos/go-oidc/v3/oidc" "github.com/coreos/go-oidc/v3/oidc"
...@@ -294,9 +295,13 @@ func CodeExchange( ...@@ -294,9 +295,13 @@ func CodeExchange(
return model.ErrorToInternalServerErrorResponse(err) return model.ErrorToInternalServerErrorResponse(err)
} }
if authInfo.PollingCode { if authInfo.PollingCode {
url := "/native"
if authInfo.ApplicationName != "" {
url = fmt.Sprintf("%s?application=%s", url, authInfo.ApplicationName)
}
return &model.Response{ return &model.Response{
Status: fiber.StatusSeeOther, Status: fiber.StatusSeeOther,
Response: "/native", Response: url,
} }
} }
res, err := ste.Token.ToTokenResponse(rlog, authInfo.ResponseType, authInfo.MaxTokenLen, networkData, "") res, err := ste.Token.ToTokenResponse(rlog, authInfo.ResponseType, authInfo.MaxTokenLen, networkData, "")
......
...@@ -70,6 +70,7 @@ func handleSSH(ctx *fiber.Ctx) error { ...@@ -70,6 +70,7 @@ func handleSSH(ctx *fiber.Ctx) error {
func handleNativeCallback(ctx *fiber.Ctx) error { func handleNativeCallback(ctx *fiber.Ctx) error {
binding := map[string]interface{}{ binding := map[string]interface{}{
emptyNavbar: true, emptyNavbar: true,
"application": ctx.Query("application"),
} }
return ctx.Render("sites/native", binding, layoutMain) return ctx.Render("sites/native", binding, layoutMain)
} }
...@@ -77,6 +78,7 @@ func handleNativeCallback(ctx *fiber.Ctx) error { ...@@ -77,6 +78,7 @@ func handleNativeCallback(ctx *fiber.Ctx) error {
func handleNativeConsentAbortCallback(ctx *fiber.Ctx) error { func handleNativeConsentAbortCallback(ctx *fiber.Ctx) error {
binding := map[string]interface{}{ binding := map[string]interface{}{
emptyNavbar: true, emptyNavbar: true,
"application": ctx.Query("application"),
} }
return ctx.Render("sites/native.abort", binding, layoutMain) return ctx.Render("sites/native.abort", binding, layoutMain)
} }
......
<h3>Aborted!</h3> <h3>Aborted!</h3>
{{#application}}
<h4>Please go back to '{{application}}'.</h4>
{{/application}}
{{^application}}
<h4>Please go back to the application that started this flow.</h4> <h4>Please go back to the application that started this flow.</h4>
{{/application}}
<h3>Success!</h3> <h3>Success!</h3>
{{#application}}
<h4>Please go back to '{{application}}'.</h4>
{{/application}}
{{^application}}
<h4>Please go back to the application that started this flow.</h4> <h4>Please go back to the application that started this flow.</h4>
{{/application}}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment