Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
chore: cleanup on some auth services
Kyle Mendellc724e47aa5e7
diff --git a/backend/internal/api/auth_handler.go b/backend/internal/api/auth_handler.goindex 53a671b45..6a3a5a2d0 100644--- a/backend/internal/api/auth_handler.go+++ b/backend/internal/api/auth_handler.go@@ -219,22 +219,6 @@ func (h *AuthHandler) GetCurrentUser(c *gin.Context) {})}-func (h *AuthHandler) ValidateSession(c *gin.Context) {- _, exists := middleware.GetCurrentUser(c)- if !exists {- c.JSON(http.StatusUnauthorized, gin.H{- "success": false,- "valid": false,- })- return- }-- c.JSON(http.StatusOK, gin.H{- "success": true,- "valid": true,- })-}-func (h *AuthHandler) RefreshToken(c *gin.Context) {var req RefreshRequestif err := c.ShouldBindJSON(&req); err != nil {diff --git a/backend/internal/api/routes.go b/backend/internal/api/routes.goindex 426704377..3059bc54b 100644--- a/backend/internal/api/routes.go+++ b/backend/internal/api/routes.go@@ -99,7 +99,6 @@ func setupAuthRoutes(api *gin.RouterGroup, services *Services) {auth.POST("/login", authHandler.Login)auth.POST("/logout", authHandler.Logout)auth.GET("/me", middleware.AuthMiddleware(services.Auth), authHandler.GetCurrentUser)- auth.GET("/validate", middleware.AuthMiddleware(services.Auth), authHandler.ValidateSession)auth.POST("/refresh", authHandler.RefreshToken)auth.POST("/password", middleware.AuthMiddleware(services.Auth), authHandler.ChangePassword)diff --git a/backend/internal/services/auth_service.go b/backend/internal/services/auth_service.goindex 5e33cfbaa..1ecb5e73e 100644--- a/backend/internal/services/auth_service.go+++ b/backend/internal/services/auth_service.go@@ -10,6 +10,7 @@ import ("github.com/gin-gonic/gin""github.com/golang-jwt/jwt/v5"+ "github.com/google/uuid""github.com/ofkm/arcane-backend/internal/config""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/models"@@ -294,6 +295,7 @@ func (s *AuthService) OidcLogin(ctx context.Context, userInfo dto.OidcUserInfo)email := userInfo.Emailuser = &models.User{+ BaseModel: models.BaseModel{ID: uuid.NewString()},Username: username,DisplayName: &displayName,Email: &email,@@ -311,13 +313,12 @@ func (s *AuthService) OidcLogin(ctx context.Context, userInfo dto.OidcUserInfo)return nil, nil, err}- // Log user login eventmetadata := models.JSON{"action": "login","method": "oidc","newUser": isNewUser,"subject": userInfo.Subject,- "ipAddress": "", // Could be extracted from context if available+ "ipAddress": "",}if logErr := s.eventService.LogUserEvent(ctx, models.EventTypeUserLogin, user.ID, user.Username, metadata); logErr != nil {fmt.Printf("Could not log OIDC user login action: %s\n", logErr)@@ -326,9 +327,7 @@ func (s *AuthService) OidcLogin(ctx context.Context, userInfo dto.OidcUserInfo)return user, tokenPair, nil}-// Add a logout method to log logout eventsfunc (s *AuthService) Logout(ctx context.Context, user *models.User) error {- // Log user logout eventmetadata := models.JSON{"action": "logout","ipAddress": "", // Could be extracted from context if availablediff --git a/backend/internal/services/oidc_service.go b/backend/internal/services/oidc_service.goindex bdeb965f9..250c4f84c 100644--- a/backend/internal/services/oidc_service.go+++ b/backend/internal/services/oidc_service.go@@ -12,7 +12,6 @@ import ("net/http""net/url""strings"- "sync""time""github.com/ofkm/arcane-backend/internal/config"@@ -21,15 +20,11 @@ import ()type OidcService struct {- authService *AuthService- config *config.Config- httpClient *http.Client- discoveryCache map[string]*dto.OidcDiscoveryDocument- cacheMutex sync.RWMutex- cacheExpiry map[string]time.Time+ authService *AuthService+ config *config.Config+ httpClient *http.Client}-// internal-only state persisted in cookietype OidcState struct {State string `json:"state"`CodeVerifier string `json:"code_verifier"`@@ -39,25 +34,13 @@ type OidcState struct {func NewOidcService(authService *AuthService, cfg *config.Config) *OidcService {return &OidcService{- authService: authService,- config: cfg,- httpClient: &http.Client{Timeout: 30 * time.Second},- discoveryCache: make(map[string]*dto.OidcDiscoveryDocument),- cacheExpiry: make(map[string]time.Time),+ authService: authService,+ config: cfg,+ httpClient: &http.Client{Timeout: 30 * time.Second},}}func (s *OidcService) discoverOidcEndpoints(ctx context.Context, issuerURL string) (*dto.OidcDiscoveryDocument, error) {- s.cacheMutex.RLock()- if cached, exists := s.discoveryCache[issuerURL]; exists {- if expiry, hasExpiry := s.cacheExpiry[issuerURL]; hasExpiry && time.Now().Before(expiry) {- s.cacheMutex.RUnlock()- return cached, nil- }- }- s.cacheMutex.RUnlock()-- // Construct well-known URLwellKnownURL := strings.TrimSuffix(issuerURL, "/") + "/.well-known/openid-configuration"req, err := http.NewRequestWithContext(ctx, http.MethodGet, wellKnownURL, nil)@@ -74,7 +57,6 @@ func (s *OidcService) discoverOidcEndpoints(ctx context.Context, issuerURL strin}defer resp.Body.Close()- // Read the response body for better error reportingbodyBytes, err := io.ReadAll(resp.Body)if err != nil {return nil, fmt.Errorf("failed to read discovery response body: %w", err)@@ -102,11 +84,6 @@ func (s *OidcService) discoverOidcEndpoints(ctx context.Context, issuerURL strindiscovery.AuthorizationEndpoint, discovery.TokenEndpoint)}- s.cacheMutex.Lock()- s.discoveryCache[issuerURL] = &discovery- s.cacheExpiry[issuerURL] = time.Now().Add(1 * time.Hour)- s.cacheMutex.Unlock()-return &discovery, nil}@@ -116,12 +93,6 @@ func (s *OidcService) getEffectiveConfig(ctx context.Context) (*models.OidcConfireturn nil, err}- // If we already have endpoints configured (legacy), use them- if config.AuthorizationEndpoint != "" && config.TokenEndpoint != "" {- return config, nil- }-- // Otherwise, discover endpointsif config.IssuerURL == "" {return nil, errors.New("either issuerUrl or explicit endpoints must be configured")}diff --git a/frontend/src/lib/services/api/auth-api-service.ts b/frontend/src/lib/services/api/auth-api-service.tsindex 5c433c89a..961ba64a3 100644--- a/frontend/src/lib/services/api/auth-api-service.ts+++ b/frontend/src/lib/services/api/auth-api-service.ts@@ -59,16 +59,6 @@ export class AuthService extends BaseAPIService {}}- async validateSession(): Promise<boolean> {- try {- const response = await this.api.get('/auth/validate');- return response.data.valid === true;- } catch (error) {- userStore.clearUser();- return false;- }- }-async changePassword(oldPassword: string, newPassword: string): Promise<void> {const response = await this.api.post('/auth/password', {currentPassword: oldPassword,