diff --git a/internal/auth/assets/index.html b/internal/auth/assets/index.html new file mode 100644 index 0000000..4664796 --- /dev/null +++ b/internal/auth/assets/index.html @@ -0,0 +1,16 @@ + + + + CalendarSync + + +
+

CalendarSync authentication successful!

+

You can now close this window.

+
+
+

The CalendarSync project is powered by:

+ +
+ + diff --git a/internal/auth/assets/inovex.png b/internal/auth/assets/inovex.png new file mode 100644 index 0000000..2548f77 Binary files /dev/null and b/internal/auth/assets/inovex.png differ diff --git a/internal/auth/handler.go b/internal/auth/handler.go index 2b22d48..40deab1 100644 --- a/internal/auth/handler.go +++ b/internal/auth/handler.go @@ -2,6 +2,7 @@ package auth import ( "context" + "embed" "net" "net/http" "net/url" @@ -12,18 +13,8 @@ import ( "golang.org/x/oauth2" ) -const successHtml = ` - - - CalendarSync - - -
-

CalendarSync authentication successful!

-

You can now close this window.

-
- -` +//go:embed assets +var assets embed.FS type OAuthHandler struct { listener net.Listener @@ -86,8 +77,13 @@ func (l *OAuthHandler) createAuthorizationExchange(ctx context.Context) func(htt // show the user a success page and stop the http listener w.WriteHeader(http.StatusOK) - if _, err := w.Write([]byte(successHtml)); err != nil { - panic(err) + successPage, err := assets.ReadFile("assets/index.html") + if err != nil { + log.Fatal("could not load auth success page", err) + } + _, err = w.Write(successPage) + if err != nil { + log.Fatal(err) } } } @@ -96,6 +92,7 @@ func (l *OAuthHandler) createAuthorizationExchange(ctx context.Context) func(htt // and the http server will shut down. func (l *OAuthHandler) Listen(ctx context.Context) error { mux := http.NewServeMux() + mux.Handle("/", http.FileServer(http.FS(assets))) mux.HandleFunc("/redirect", l.createAuthorizationExchange(ctx)) if err := http.Serve(l.listener, mux); err != nil {