11package auth
22
33import (
4- "embed"
4+ _ "embed"
55 "encoding/json"
66 "errors"
77 "fmt"
@@ -11,12 +11,12 @@ import (
1111 "net/http"
1212 "os"
1313 "os/exec"
14- "path"
1514 "runtime"
1615 "strconv"
1716 "strings"
1817 "time"
1918
19+ "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
2020 "golang.org/x/oauth2"
2121
2222 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
@@ -26,22 +26,23 @@ const (
2626 defaultWellKnownConfig = "https://accounts.stackit.cloud/.well-known/openid-configuration"
2727 defaultCLIClientID = "stackit-cli-0000-0000-000000000001"
2828
29- loginSuccessPath = "/login-successful"
30- stackitLandingPage = "https://www.stackit.de"
31- htmlTemplatesPath = "templates"
32- loginSuccessfulHTMLFile = "login-successful.html"
29+ loginSuccessPath = "/login-successful"
3330
3431 // The IDP doesn't support wildcards for the port,
3532 // so we configure a range of ports from 8000 to 8020
3633 defaultPort = 8000
3734 configuredPortRange = 20
3835)
3936
40- //go:embed templates/*
41- var htmlContent embed. FS
37+ //go:embed templates/login-successful.html
38+ var htmlTemplateContent string
4239
43- type User struct {
40+ //go:embed templates/stackit_nav_logo_light.svg
41+ var logoSvgContent []byte
42+
43+ type InputValues struct {
4444 Email string
45+ Logo string
4546}
4647
4748type apiClient interface {
@@ -215,18 +216,19 @@ func AuthorizeUser(p *print.Printer, isReauthentication bool) error {
215216 errServer = fmt .Errorf ("read user email: %w" , err )
216217 }
217218
218- user := User {
219+ input := InputValues {
219220 Email : email ,
221+ Logo : utils .Base64Encode (logoSvgContent ),
220222 }
221223
222224 // ParseFS expects paths using forward slashes, even on Windows
223225 // See: https://github.com/golang/go/issues/44305#issuecomment-780111748
224- htmlTemplate , err := template .ParseFS ( htmlContent , path . Join ( htmlTemplatesPath , loginSuccessfulHTMLFile ) )
226+ htmlTemplate , err := template .New ( "loginSuccess" ). Parse ( htmlTemplateContent )
225227 if err != nil {
226228 errServer = fmt .Errorf ("parse html file: %w" , err )
227229 }
228230
229- err = htmlTemplate .Execute (w , user )
231+ err = htmlTemplate .Execute (w , input )
230232 if err != nil {
231233 errServer = fmt .Errorf ("render page: %w" , err )
232234 }
0 commit comments