Skip to content

Commit ce73945

Browse files
committed
fix instance-url in consent screen might having double slash
1 parent f78615e commit ce73945

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed

internal/endpoints/consent/consent.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,32 @@ import (
3737
func handleConsent(ctx *fiber.Ctx, info *pkg2.OIDCFlowRequest, includeConsentCallbacks bool) error {
3838
c := info.Capabilities
3939
binding := map[string]interface{}{
40-
"consent": true,
41-
"consent-send": includeConsentCallbacks,
42-
"empty-navbar": true,
43-
"restr-gui": true,
44-
"collapse": templating.Collapsable{All: true},
45-
"restrictions": pkg.WebRestrictions{Restrictions: info.Restrictions},
46-
"capabilities": pkg.AllWebCapabilities(),
47-
"subtoken-capabilities": pkg.AllWebCapabilities(),
48-
"checked-capabilities": c.Strings(),
49-
"iss": info.Issuer,
50-
"supported_scopes": strings.Join(config.Get().ProviderByIssuer[info.Issuer].Scopes, " "),
51-
"token-name": info.Name,
52-
"rotation": info.Rotation,
53-
"application": info.ApplicationName,
40+
templating.MustacheKeyConsent: true,
41+
templating.MustacheKeyConsentSend: includeConsentCallbacks,
42+
templating.MustacheKeyEmptyNavbar: true,
43+
templating.MustacheKeyRestrictionsGUI: true,
44+
templating.MustacheKeyCollapse: templating.Collapsable{All: true},
45+
templating.MustacheKeyRestrictions: pkg.WebRestrictions{Restrictions: info.Restrictions},
46+
templating.MustacheKeyCapabilities: pkg.AllWebCapabilities(),
47+
templating.MustacheKeySubtokenCapabilities: pkg.AllWebCapabilities(),
48+
templating.MustacheKeyCheckedCapabilities: c.Strings(),
49+
templating.MustacheKeyIss: info.Issuer,
50+
templating.MustacheKeySupportedScopes: strings.Join(
51+
config.Get().ProviderByIssuer[info.Issuer].Scopes, " ",
52+
),
53+
templating.MustacheKeyTokenName: info.Name,
54+
templating.MustacheKeyRotation: info.Rotation,
55+
templating.MustacheKeyApplication: info.ApplicationName,
5456
}
5557
if c.Has(api.CapabilityCreateMT) {
56-
binding["checked-subtoken-capabilities"] = info.SubtokenCapabilities.Strings()
58+
binding[templating.MustacheKeyCheckedSubtokenCapabilities] = info.SubtokenCapabilities.Strings()
5759
}
5860
if !includeConsentCallbacks {
59-
binding["instance-url"] = config.Get().IssuerURL
61+
iss := config.Get().IssuerURL
62+
if iss[len(iss)-1] == '/' {
63+
iss = iss[:len(iss)-1]
64+
}
65+
binding[templating.MustacheKeyInstanceUrl] = iss
6066
}
6167
return ctx.Render("sites/consent", binding, "layouts/main")
6268
}

internal/utils/templating/keys.go

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,34 @@ const LayoutMain = "layouts/main"
55

66
// Keys used in the mustache templates
77
const (
8-
MustacheKeyHome = "home"
9-
MustacheKeyCapabilities = "capabilities"
10-
MustacheKeySubtokenCapabilities = "subtoken-capabilities"
11-
MustacheKeyEmptyNavbar = "empty-navbar"
12-
MustacheKeyLoggedIn = "logged-in"
13-
MustacheKeyRestrictionsGUI = "restr-gui"
14-
MustacheKeyRestrictions = "restrictions"
15-
MustacheKeyCookieLifetime = "cookie-lifetime"
16-
MustacheKeyPrefix = "prefix"
17-
MustacheKeyReadOnly = "read-only"
18-
MustacheKeyCollapse = "collapse"
19-
MustacheKeySettings = "settings"
20-
MustacheKeySettingsSSH = "settings-ssh"
21-
MustacheKeyGrants = "grants"
22-
MustacheKeyApplication = "application"
23-
MustacheKeyName = "name"
24-
MustacheKeyHomepage = "homepage"
25-
MustacheKeyContact = "contact"
26-
MustacheKeyPrivacyContact = "privacy-contact"
8+
MustacheKeyHome = "home"
9+
MustacheKeyCapabilities = "capabilities"
10+
MustacheKeySubtokenCapabilities = "subtoken-capabilities"
11+
MustacheKeyCheckedCapabilities = "checked-capabilities"
12+
MustacheKeyCheckedSubtokenCapabilities = "checked-subtoken-capabilities"
13+
MustacheKeyEmptyNavbar = "empty-navbar"
14+
MustacheKeyLoggedIn = "logged-in"
15+
MustacheKeyRestrictionsGUI = "restr-gui"
16+
MustacheKeyRestrictions = "restrictions"
17+
MustacheKeyRotation = "rotation"
18+
MustacheKeyCookieLifetime = "cookie-lifetime"
19+
MustacheKeyPrefix = "prefix"
20+
MustacheKeyReadOnly = "read-only"
21+
MustacheKeyCollapse = "collapse"
22+
MustacheKeySettings = "settings"
23+
MustacheKeySettingsSSH = "settings-ssh"
24+
MustacheKeyGrants = "grants"
25+
MustacheKeyApplication = "application"
26+
MustacheKeyName = "name"
27+
MustacheKeyHomepage = "homepage"
28+
MustacheKeyContact = "contact"
29+
MustacheKeyPrivacyContact = "privacy-contact"
30+
MustacheKeyConsent = "consent"
31+
MustacheKeyConsentSend = "consent-send"
32+
MustacheKeyTokenName = "token-name"
33+
MustacheKeyIss = "iss"
34+
MustacheKeySupportedScopes = "supported_scopes"
35+
MustacheKeyInstanceUrl = "instance-url"
2736
)
2837

2938
// Keys for sub configs

0 commit comments

Comments
 (0)