Feat rebrand armature (#43)
All checks were successful
All checks were successful
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #43.
This commit is contained in:
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"switchboard-core/auth"
|
||||
"switchboard-core/store"
|
||||
"armature/auth"
|
||||
"armature/store"
|
||||
)
|
||||
|
||||
// RequireAdmin returns middleware that restricts access to users with the
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
|
||||
"switchboard-core/config"
|
||||
"switchboard-core/database"
|
||||
"switchboard-core/store"
|
||||
"armature/config"
|
||||
"armature/database"
|
||||
"armature/store"
|
||||
)
|
||||
|
||||
// Claims represents the JWT payload. Must match handlers.Claims.
|
||||
@@ -142,11 +142,11 @@ func parseAndValidateJWT(tokenString string, jwtSecret string) (*Claims, bool) {
|
||||
return claims, true
|
||||
}
|
||||
|
||||
// UserIDFromCookie extracts the user ID from the sb_token cookie without
|
||||
// UserIDFromCookie extracts the user ID from the arm_token cookie without
|
||||
// requiring authentication. Returns "" if no valid token is found.
|
||||
// Used by unauthenticated routes that want optional user context.
|
||||
func UserIDFromCookie(c *gin.Context, jwtSecret string) string {
|
||||
cookie, err := c.Cookie("sb_token")
|
||||
cookie, err := c.Cookie("arm_token")
|
||||
if err != nil || cookie == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -7,17 +7,17 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"switchboard-core/auth"
|
||||
"switchboard-core/config"
|
||||
"switchboard-core/database"
|
||||
"switchboard-core/store"
|
||||
"armature/auth"
|
||||
"armature/config"
|
||||
"armature/database"
|
||||
"armature/store"
|
||||
)
|
||||
|
||||
// AuthOrRedirect validates JWT tokens for page routes.
|
||||
// Unlike Auth() which returns 401 JSON for API calls, this redirects
|
||||
// to the login page — appropriate for browser navigation.
|
||||
//
|
||||
// Token is read from the "sb_token" cookie (set by the login page JS)
|
||||
// Token is read from the "arm_token" cookie (set by the login page JS)
|
||||
// since page requests don't have Authorization headers.
|
||||
func AuthOrRedirect(cfg *config.Config, users store.UserStore, cache *UserStatusCache) gin.HandlerFunc {
|
||||
loginPath := cfg.BasePath + "/login"
|
||||
@@ -32,7 +32,7 @@ func AuthOrRedirect(cfg *config.Config, users store.UserStore, cache *UserStatus
|
||||
// Try cookie first (set by login page), then Authorization header,
|
||||
// then query param (for edge cases)
|
||||
tokenString := ""
|
||||
if cookie, err := c.Cookie("sb_token"); err == nil && cookie != "" {
|
||||
if cookie, err := c.Cookie("arm_token"); err == nil && cookie != "" {
|
||||
tokenString = cookie
|
||||
}
|
||||
if tokenString == "" {
|
||||
@@ -109,7 +109,7 @@ func OptionalAuth(cfg *config.Config, users store.UserStore, cache *UserStatusCa
|
||||
}
|
||||
|
||||
tokenString := ""
|
||||
if cookie, err := c.Cookie("sb_token"); err == nil && cookie != "" {
|
||||
if cookie, err := c.Cookie("arm_token"); err == nil && cookie != "" {
|
||||
tokenString = cookie
|
||||
}
|
||||
if tokenString == "" {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"switchboard-core/auth"
|
||||
"switchboard-core/store"
|
||||
"armature/auth"
|
||||
"armature/store"
|
||||
)
|
||||
|
||||
const permCacheKey = "resolved_permissions"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"switchboard-core/metrics"
|
||||
"armature/metrics"
|
||||
)
|
||||
|
||||
// Prometheus returns a Gin middleware that records HTTP request metrics.
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"switchboard-core/store"
|
||||
"armature/store"
|
||||
)
|
||||
|
||||
// RateLimiter implements per-IP rate limiting backed by a shared store.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"switchboard-core/store"
|
||||
"armature/store"
|
||||
)
|
||||
|
||||
// RequireTeamAdmin returns middleware that restricts access to team admins.
|
||||
|
||||
Reference in New Issue
Block a user