1
1
package auth
2
2
3
3
import (
4
- "embed"
4
+ _ "embed"
5
5
"encoding/json"
6
6
"errors"
7
7
"fmt"
@@ -11,12 +11,12 @@ import (
11
11
"net/http"
12
12
"os"
13
13
"os/exec"
14
- "path"
15
14
"runtime"
16
15
"strconv"
17
16
"strings"
18
17
"time"
19
18
19
+ "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
20
20
"golang.org/x/oauth2"
21
21
22
22
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
@@ -26,22 +26,23 @@ const (
26
26
defaultWellKnownConfig = "https://accounts.stackit.cloud/.well-known/openid-configuration"
27
27
defaultCLIClientID = "stackit-cli-0000-0000-000000000001"
28
28
29
- loginSuccessPath = "/login-successful"
30
- stackitLandingPage = "https://www.stackit.de"
31
- htmlTemplatesPath = "templates"
32
- loginSuccessfulHTMLFile = "login-successful.html"
29
+ loginSuccessPath = "/login-successful"
33
30
34
31
// The IDP doesn't support wildcards for the port,
35
32
// so we configure a range of ports from 8000 to 8020
36
33
defaultPort = 8000
37
34
configuredPortRange = 20
38
35
)
39
36
40
- //go:embed templates/*
41
- var htmlContent embed. FS
37
+ //go:embed templates/login-successful.html
38
+ var htmlTemplateContent string
42
39
43
- type User struct {
40
+ //go:embed templates/stackit_nav_logo_light.svg
41
+ var logoSvgContent []byte
42
+
43
+ type InputValues struct {
44
44
Email string
45
+ Logo string
45
46
}
46
47
47
48
type apiClient interface {
@@ -215,18 +216,19 @@ func AuthorizeUser(p *print.Printer, isReauthentication bool) error {
215
216
errServer = fmt .Errorf ("read user email: %w" , err )
216
217
}
217
218
218
- user := User {
219
+ input := InputValues {
219
220
Email : email ,
221
+ Logo : utils .Base64Encode (logoSvgContent ),
220
222
}
221
223
222
224
// ParseFS expects paths using forward slashes, even on Windows
223
225
// 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 )
225
227
if err != nil {
226
228
errServer = fmt .Errorf ("parse html file: %w" , err )
227
229
}
228
230
229
- err = htmlTemplate .Execute (w , user )
231
+ err = htmlTemplate .Execute (w , input )
230
232
if err != nil {
231
233
errServer = fmt .Errorf ("render page: %w" , err )
232
234
}
0 commit comments