Verified Commit e70aeea0 authored by Patrick Rice's avatar Patrick Rice 🫖 Committed by GitLab
Browse files

Merge branch 'tv/2026-02/cli-oauth-confirmation-2' into 'main'

chore(oauth): use go:embed to extract the html

See merge request !2740
parents 5a2d6ede e7135b11
Loading
Loading
Loading
Loading
Loading
+5 −40
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ package gitlaboauth2

import (
	"context"
	_ "embed"
	"errors"
	"fmt"
	"net/http"
@@ -13,6 +14,9 @@ import (
	"golang.org/x/oauth2"
)

//go:embed success.html
var successHTML []byte

// CallbackServer handles the OAuth2 callback flow for GitLab authentication.
//
// This server provides a complete OAuth2 flow implementation that:
@@ -231,46 +235,7 @@ func (s *CallbackServer) callbackHandler(ctx context.Context, tokenChan chan *oa
		// Send success response
		tokenChan <- token
		w.Header().Set("Content-Type", "text/html; charset=utf-8")
		_, _ = w.Write([]byte(`<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Authentication Successful</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            margin: 0;
            background: #fafafa;
        }
        .container {
            text-align: center;
            padding: 2rem;
        }
        h1 {
            color: #108548;
            font-size: 1.5rem;
            font-weight: 600;
            margin: 0 0 0.5rem 0;
        }
        p {
            color: #666;
            margin: 0;
            line-height: 1.5;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>✓ Authentication Successful!</h1>
        <p>You can close this window and return to the application.</p>
    </div>
</body>
</html>`))
		_, _ = w.Write(successHTML)
	}
}

+40 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Authentication Successful</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            margin: 0;
            background: #fafafa;
        }
        .container {
            text-align: center;
            padding: 2rem;
        }
        h1 {
            color: #108548;
            font-size: 1.5rem;
            font-weight: 600;
            margin: 0 0 0.5rem 0;
        }
        p {
            color: #666;
            margin: 0;
            line-height: 1.5;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>✓ Authentication Successful!</h1>
        <p>You can close this window and return to the application.</p>
    </div>
</body>
</html>