Skip to content

Commit

Permalink
Add simple favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
Jipok committed Mar 4, 2024
1 parent 859f35e commit d3640b2
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 5 deletions.
6 changes: 6 additions & 0 deletions auth-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func newAuthMux(handler http.Handler) *http.ServeMux {
}
mux.HandleFunc(cfg.LogoutURL, handleLogout)
mux.HandleFunc("/jauth-check", handleCheckAuth)
mux.HandleFunc("/jauth-favicon", handleFavicon)
// This is necessary to make a closure and forward the reverse proxy to the handler function
auth := buildAuthHandler(handler)
mux.Handle("/", auth)
Expand All @@ -53,6 +54,11 @@ func writeIndexPage(w http.ResponseWriter, req *http.Request) {
w.Write(page)
}

func handleFavicon(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "image/svg+xml")
w.Write(embed_favicon)
}

// Handler of cfg.LogoutURL
func handleLogout(w http.ResponseWriter, req *http.Request) {
cookie, err := req.Cookie("jauth_token")
Expand Down
13 changes: 8 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,20 @@ var (
domains = map[string]Domain_Info{}
)

// Next comment will embed `index.html` file into executable during compile time
// Next comments will embed files into executable during compile time
//
//go:embed index.html
var embed_index_html string
//go:embed www/index.html
var embed_index_html []byte

//go:embed NotInWhitelist.html
//go:embed www/NotInWhitelist.html
var NotInWhitelist_PAGE string

//go:embed 502.html
//go:embed www/502.html
var embed_502_html []byte

//go:embed www/favicon.svg
var embed_favicon []byte

func main() {
// Config filename can be provided via command line
config_file := "jauth.toml"
Expand Down
1 change: 1 addition & 0 deletions 502.html → www/502.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="/jauth-favicon">
<title>Error 502 - Bad Gateway</title>
<style>
body {
Expand Down
1 change: 1 addition & 0 deletions NotInWhitelist.html → www/NotInWhitelist.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="/jauth-favicon">
<title>Login Page</title>
<style>
body {
Expand Down
76 changes: 76 additions & 0 deletions www/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions index.html → www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="/jauth-favicon">
<title>Login Page</title>
<style>
* {
Expand Down

0 comments on commit d3640b2

Please sign in to comment.