Skip to content

Commit

Permalink
define route for /tls-warning
Browse files Browse the repository at this point in the history
rename route from /insecure -> /tls-warning
  • Loading branch information
miaawong committed Nov 1, 2024
1 parent 99139b5 commit 7616a96
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kurl_proxy/assets/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
.replace(/\/$/, "");
var httpsLink = "http:" + rawLink;
var opensslLink = rawLink.substring(2).replace("/", "");
var insecureLink = httpsLink + "/insecure";
var insecureLink = httpsLink + "/tls-warning";
</script>
<body>
<div class="u-minHeight--full u-width--full flex flex-column flex1">
Expand Down
31 changes: 27 additions & 4 deletions kurl_proxy/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,34 @@ func getHttpServer(fingerprint string, acceptAnonymousUploads bool, assetsDir st
}

appIcon := template.URL(app.Spec.Icon)
htmlPage := "welcome.html"
if c.Request.URL.Path == "/insecure" {
htmlPage = "insecure.html"
c.HTML(http.StatusOK, "welcome.html", gin.H{
"fingerprintSHA1": fingerprint,
"AppIcon": appIcon,
"AppTitle": app.Spec.Title,
"IsEmbeddedCluster": isEmbeddedCluster(),
})
})
r.GET("/tls-warning", func(c *gin.Context) {
if !acceptAnonymousUploads {
log.Println("TLS certs already uploaded, redirecting to https")
target := url.URL{
Scheme: "https",
Host: c.Request.Host,
Path: c.Request.URL.Path,
RawQuery: c.Request.URL.RawQuery,
}
// Returns StatusFound (302) to avoid browser caching
c.Redirect(http.StatusFound, target.String())
return
}

app, err := kotsadmApplication()

if err != nil {
log.Printf("No kotsadm application metadata: %v", err) // continue
}
c.HTML(http.StatusOK, htmlPage, gin.H{
appIcon := template.URL(app.Spec.Icon)
c.HTML(http.StatusOK, "insecure.html", gin.H{
"fingerprintSHA1": fingerprint,
"AppIcon": appIcon,
"AppTitle": app.Spec.Title,
Expand Down

0 comments on commit 7616a96

Please sign in to comment.