mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 02:43:05 +00:00
Fixed errors in files according to golangci-lint rules
This commit is contained in:
parent
6997becdd3
commit
612adf787a
3 changed files with 26 additions and 30 deletions
|
@ -7,7 +7,6 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/juanfont/headscale/hscontrol/templates"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -17,6 +16,7 @@ import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/juanfont/headscale/hscontrol/db"
|
"github.com/juanfont/headscale/hscontrol/db"
|
||||||
"github.com/juanfont/headscale/hscontrol/notifier"
|
"github.com/juanfont/headscale/hscontrol/notifier"
|
||||||
|
"github.com/juanfont/headscale/hscontrol/templates"
|
||||||
"github.com/juanfont/headscale/hscontrol/types"
|
"github.com/juanfont/headscale/hscontrol/types"
|
||||||
"github.com/juanfont/headscale/hscontrol/util"
|
"github.com/juanfont/headscale/hscontrol/util"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
@ -116,7 +116,7 @@ func (a *AuthProviderOIDC) determineNodeExpiry(idTokenExpiration time.Time) time
|
||||||
return time.Now().Add(a.cfg.Expiry)
|
return time.Now().Add(a.cfg.Expiry)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterOIDC redirects to the OIDC provider for authentication
|
// RegisterHandler redirects to the OIDC provider for authentication
|
||||||
// Puts NodeKey in cache so the callback can retrieve it using the oidc state param
|
// Puts NodeKey in cache so the callback can retrieve it using the oidc state param
|
||||||
// Listens in /register/:mKey.
|
// Listens in /register/:mKey.
|
||||||
func (a *AuthProviderOIDC) RegisterHandler(
|
func (a *AuthProviderOIDC) RegisterHandler(
|
||||||
|
@ -171,11 +171,6 @@ func (a *AuthProviderOIDC) RegisterHandler(
|
||||||
http.Redirect(writer, req, authURL, http.StatusFound)
|
http.Redirect(writer, req, authURL, http.StatusFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
type oidcCallbackTemplateConfig struct {
|
|
||||||
User string
|
|
||||||
Verb string
|
|
||||||
}
|
|
||||||
|
|
||||||
// OIDCCallbackHandler handles the callback from the OIDC endpoint
|
// OIDCCallbackHandler handles the callback from the OIDC endpoint
|
||||||
// Retrieves the nkey from the state cache and adds the node to the users email user
|
// Retrieves the nkey from the state cache and adds the node to the users email user
|
||||||
// TODO: A confirmation page for new nodes should be added to avoid phishing vulnerabilities
|
// TODO: A confirmation page for new nodes should be added to avoid phishing vulnerabilities
|
||||||
|
|
|
@ -33,7 +33,7 @@ func logo(class string) *elem.Element {
|
||||||
styles.Var("fill-rule"): "evenodd",
|
styles.Var("fill-rule"): "evenodd",
|
||||||
styles.Var("clip-rule"): "evenodd",
|
styles.Var("clip-rule"): "evenodd",
|
||||||
styles.Var("stroke-linejoin"): "round",
|
styles.Var("stroke-linejoin"): "round",
|
||||||
styles.Var("stroke-miterlimit"): styles.Int(2),
|
styles.Var("stroke-miterlimit"): styles.Int(2), //nolint
|
||||||
}.ToInline(),
|
}.ToInline(),
|
||||||
"viewBox": "0 0 1280 640",
|
"viewBox": "0 0 1280 640",
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,7 @@ package templates
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/chasefleming/elem-go"
|
"github.com/chasefleming/elem-go"
|
||||||
"github.com/chasefleming/elem-go/attrs"
|
"github.com/chasefleming/elem-go/attrs"
|
||||||
"github.com/chasefleming/elem-go/styles"
|
"github.com/chasefleming/elem-go/styles"
|
||||||
|
@ -11,7 +12,7 @@ import (
|
||||||
func OidcCallback(node *types.Node, user *types.User, verb string) string {
|
func OidcCallback(node *types.Node, user *types.User, verb string) string {
|
||||||
styleMgr := styles.NewStyleManager()
|
styleMgr := styles.NewStyleManager()
|
||||||
styleBody := styleMgr.AddStyle(styles.Props{
|
styleBody := styleMgr.AddStyle(styles.Props{
|
||||||
styles.FontSize: styles.Pixels(14),
|
styles.FontSize: styles.Pixels(14), //nolint
|
||||||
styles.FontFamily: "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif",
|
styles.FontFamily: "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif",
|
||||||
})
|
})
|
||||||
styleHr := styleMgr.AddStyle(styles.Props{
|
styleHr := styleMgr.AddStyle(styles.Props{
|
||||||
|
@ -22,12 +23,12 @@ func OidcCallback(node *types.Node, user *types.User, verb string) string {
|
||||||
styles.Display: "flex",
|
styles.Display: "flex",
|
||||||
styles.JustifyContent: "center",
|
styles.JustifyContent: "center",
|
||||||
styles.AlignItems: "center",
|
styles.AlignItems: "center",
|
||||||
styles.Height: styles.ViewportHeight(70),
|
styles.Height: styles.ViewportHeight(70), //nolint
|
||||||
})
|
})
|
||||||
classLogo := styleMgr.AddStyle(styles.Props{
|
classLogo := styleMgr.AddStyle(styles.Props{
|
||||||
styles.Display: "block",
|
styles.Display: "block",
|
||||||
styles.MarginLeft: styles.Pixels(-20),
|
styles.MarginLeft: styles.Pixels(-20), //nolint
|
||||||
styles.MarginBottom: styles.Pixels(16),
|
styles.MarginBottom: styles.Pixels(16), //nolint
|
||||||
})
|
})
|
||||||
|
|
||||||
colorMessageSuccess := styles.Props{
|
colorMessageSuccess := styles.Props{
|
||||||
|
@ -40,12 +41,12 @@ func OidcCallback(node *types.Node, user *types.User, verb string) string {
|
||||||
}
|
}
|
||||||
styleMessage := styles.Props{
|
styleMessage := styles.Props{
|
||||||
styles.Display: "flex",
|
styles.Display: "flex",
|
||||||
styles.MinWidth: styles.ViewportWidth(40),
|
styles.MinWidth: styles.ViewportWidth(40), //nolint
|
||||||
styles.MarginBottom: styles.Pixels(12),
|
styles.MarginBottom: styles.Pixels(12), //nolint
|
||||||
styles.Padding: "12px 16px 16px 12px",
|
styles.Padding: "12px 16px 16px 12px",
|
||||||
styles.Position: "relative",
|
styles.Position: "relative",
|
||||||
styles.BorderRadius: styles.Pixels(2),
|
styles.BorderRadius: styles.Pixels(2), //nolint
|
||||||
styles.FontSize: styles.Pixels(14),
|
styles.FontSize: styles.Pixels(14), //nolint
|
||||||
}
|
}
|
||||||
|
|
||||||
var classMessage string
|
var classMessage string
|
||||||
|
@ -56,7 +57,7 @@ func OidcCallback(node *types.Node, user *types.User, verb string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
classMessageContent := styleMgr.AddStyle(styles.Props{
|
classMessageContent := styleMgr.AddStyle(styles.Props{
|
||||||
styles.MarginLeft: styles.Pixels(4),
|
styles.MarginLeft: styles.Pixels(4), //nolint
|
||||||
})
|
})
|
||||||
classIconSuccess := styleMgr.AddStyle(styles.Props{
|
classIconSuccess := styleMgr.AddStyle(styles.Props{
|
||||||
"fill": "#2eb039",
|
"fill": "#2eb039",
|
||||||
|
@ -69,9 +70,9 @@ func OidcCallback(node *types.Node, user *types.User, verb string) string {
|
||||||
styles.Color: "#d58525",
|
styles.Color: "#d58525",
|
||||||
}
|
}
|
||||||
styleMessageTitle := styles.Props{
|
styleMessageTitle := styles.Props{
|
||||||
styles.FontSize: styles.Pixels(16),
|
styles.FontSize: styles.Pixels(16), //nolint
|
||||||
styles.FontWeight: styles.Int(700),
|
styles.FontWeight: styles.Int(700), //nolint
|
||||||
styles.LineHeight: styles.Float(1.25),
|
styles.LineHeight: styles.Float(1.25), //nolint
|
||||||
}
|
}
|
||||||
|
|
||||||
var classMessageTitle string
|
var classMessageTitle string
|
||||||
|
@ -88,11 +89,11 @@ func OidcCallback(node *types.Node, user *types.User, verb string) string {
|
||||||
styles.Color: "#824c0b",
|
styles.Color: "#824c0b",
|
||||||
}
|
}
|
||||||
styleMessageBody := styles.Props{
|
styleMessageBody := styles.Props{
|
||||||
styles.FontSize: styles.Pixels(12),
|
styles.FontSize: styles.Pixels(12), //nolint
|
||||||
styles.Margin: styles.Int(0),
|
styles.Margin: styles.Int(0), //nolint
|
||||||
styles.Padding: styles.Int(0),
|
styles.Padding: styles.Int(0), //nolint
|
||||||
styles.Border: styles.Int(0),
|
styles.Border: styles.Int(0), //nolint
|
||||||
styles.MarginTop: styles.Pixels(4),
|
styles.MarginTop: styles.Pixels(4), //nolint
|
||||||
}
|
}
|
||||||
|
|
||||||
var classMessageBody string
|
var classMessageBody string
|
||||||
|
@ -108,7 +109,7 @@ func OidcCallback(node *types.Node, user *types.User, verb string) string {
|
||||||
styles.Margin: "8px 0",
|
styles.Margin: "8px 0",
|
||||||
styles.Color: "#1563ff",
|
styles.Color: "#1563ff",
|
||||||
styles.TextDecoration: "none",
|
styles.TextDecoration: "none",
|
||||||
styles.FontWeight: styles.Int(600),
|
styles.FontWeight: styles.Int(600), //nolint
|
||||||
},
|
},
|
||||||
PseudoClasses: map[string]styles.Props{
|
PseudoClasses: map[string]styles.Props{
|
||||||
styles.PseudoHover: {styles.Color: "black"},
|
styles.PseudoHover: {styles.Color: "black"},
|
||||||
|
@ -118,14 +119,14 @@ func OidcCallback(node *types.Node, user *types.User, verb string) string {
|
||||||
styles.AlignItems: "center",
|
styles.AlignItems: "center",
|
||||||
styles.Display: "inline-flex",
|
styles.Display: "inline-flex",
|
||||||
styles.JustifyContent: "center",
|
styles.JustifyContent: "center",
|
||||||
styles.Width: styles.Pixels(21),
|
styles.Width: styles.Pixels(21), //nolint
|
||||||
styles.Height: styles.Pixels(21),
|
styles.Height: styles.Pixels(21), //nolint
|
||||||
styles.VerticalAlign: "middle",
|
styles.VerticalAlign: "middle",
|
||||||
})
|
})
|
||||||
styleH1 := styleMgr.AddStyle(styles.Props{
|
styleH1 := styleMgr.AddStyle(styles.Props{
|
||||||
styles.FontSize: "17.5px",
|
styles.FontSize: "17.5px",
|
||||||
styles.FontWeight: styles.Pixels(700),
|
styles.FontWeight: styles.Pixels(700), //nolint
|
||||||
styles.MarginBottom: styles.Pixels(0),
|
styles.MarginBottom: styles.Pixels(0), //nolint
|
||||||
})
|
})
|
||||||
styleH1P := styleMgr.AddStyle(styles.Props{
|
styleH1P := styleMgr.AddStyle(styles.Props{
|
||||||
styles.Margin: "8px 0 16px 0",
|
styles.Margin: "8px 0 16px 0",
|
||||||
|
|
Loading…
Reference in a new issue