Repository: jamcalli/Pulsarr
Pull request #116: feat: implement authentication method configuration and local IP bypa…
Author: login: jamcalli
Created: 2025-04-26T06:25:47Z | Merged: 2025-04-26T07:13:57Z

Implement authentication method configuration and local IP bypass logic

## Description
<!-- A clear and concise description of the changes in this PR -->

Added bypass local ip environment settings. Can be completely disabled, by pass for local addresses, or enabled (default).

## Related Issues
<!-- Link to any related issues this PR addresses (e.g., "Fixes #123", "Addresses #456") -->

## Type of Change
<!-- Please delete options that are not relevant -->
- [ ] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Performance improvement
- [ ] Code refactoring
- [ ] Documentation update
- [ ] Dependency update

## Testing Performed
<!-- Describe the testing you've done to verify your changes -->

## Screenshots
<!-- If applicable, add screenshots to help explain your changes -->

## Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] My changes work with existing functionality

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added support for configurable authentication modes: required, disabled, or bypassed for local IP addresses.
  - Introduced local IP detection to enable conditional authentication bypass and ephemeral admin sessions.
  - Enhanced logout behavior to provide clear feedback when logout is unavailable due to disabled authentication.

- **Bug Fixes**
  - Improved logout handling to prevent misleading success messages when authentication is disabled.

- **Chores**
  - Updated configuration schema and types to include new authentication mode settings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/src/app.ts b/src/app.ts
index abd7ae69b..ec02b1d8e 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -4,6 +4,8 @@ import fastifyAutoload from '@fastify/autoload'
 import FastifyVite from '@fastify/vite'
 import type { FastifyInstance, FastifyPluginOptions } from 'fastify'
 import FastifyFormBody from '@fastify/formbody'
+import { isLocalIpAddress } from '@utils/ip.js'
+import { createTemporaryAdminSession } from '@utils/session.js'
 
 export const options = {
   ajv: {
@@ -14,6 +16,14 @@ export const options = {
   },
 }
 
+/**
+ * Configures and initializes the Fastify server with plugin loading, Vite integration, error handling, and authentication-aware routing.
+ *
+ * Sets up form body parsing, autoloads external and custom plugins, and registers route handlers. Integrates Vite for SPA support. Implements global error and 404 handlers with logging and rate limiting. Defines root and app routes with conditional authentication logic, supporting disabled authentication, local IP bypass, and temporary admin sessions based on user existence and configuration.
+ *
+ * @remark
+ * Authentication can be bypassed for local IPs or when disabled in configuration. Temporary admin sessions are created for local or disabled authentication if admin users exist; otherwise, users are redirected to create a user account.
+ */
 export default async function serviceApp(
   fastify: FastifyInstance,
   opts: FastifyPluginOptions,
@@ -104,10 +114,32 @@ export default async function serviceApp(
   })
 
   fastify.get('/', async (request, reply) => {
+    // Check for existing session
     if (request.session.user) {
       return reply.redirect('/app/dashboard')
     }
 
+    // Check authentication method setting
+    const authMethod = fastify.config.authenticationMethod
+    const isAuthDisabled = authMethod === 'disabled'
+    const isLocalBypass =
+      authMethod === 'requiredExceptLocal' && isLocalIpAddress(request.ip)
+
+    if (isAuthDisabled || isLocalBypass) {
+      const hasUsers = await fastify.db.hasAdminUsers()
+
+      if (hasUsers) {
+        // Create a temporary session
+        createTemporaryAdminSession(request)
+
+        return reply.redirect('/app/dashboard')
+      }
+
+      // No users exist yet, redirect to create user
+      return reply.redirect('/app/create-user')
+    }
+
+    // Normal flow - check if users exist
     const hasUsers = await fastify.db.hasAdminUsers()
     return reply.redirect(hasUsers ? '/app/login' : '/app/create-user')
   })
@@ -116,11 +148,18 @@ export default async function serviceApp(
     '/app/*',
     {
       preHandler: async (request, reply) => {
+        // Check authentication method setting
+        const authMethod = fastify.config.authenticationMethod
+        const isAuthDisabled = authMethod === 'disabled'
+        const isLocalBypass =
+          authMethod === 'requiredExceptLocal' && isLocalIpAddress(request.ip)
+
+        // For login and create-user pages
         if (
           request.url === '/app/login' ||
           request.url === '/app/create-user'
         ) {
-          if (request.session.user) {
+          if (request.session.user || isAuthDisabled || isLocalBypass) {
             return reply.redirect('/app/dashboard')
           }
 
@@ -137,8 +176,24 @@ export default async function serviceApp(
           return
         }
 
+        // For all other app pages
         if (!request.session.user) {
-          return reply.redirect('/app/login')
+          // If auth is disabled or this is a local connection with local bypass
+          if (isAuthDisabled || isLocalBypass) {
+            // Create a temporary session for the current request only
+            const hasUsers = await fastify.db.hasAdminUsers()
+
+            if (hasUsers) {
+              // Use a temporary session
+              createTemporaryAdminSession(request)
+            } else {
+              // No users exist yet, redirect to create user
+              return reply.redirect('/app/create-user')
+            }
+          } else {
+            // Regular auth required - redirect to login
+            return reply.redirect('/app/login')
+          }
         }
       },
     },
diff --git a/src/client/components/ui/logout-alert.tsx b/src/client/components/ui/logout-alert.tsx
index 83255d702..21671ac35 100644
--- a/src/client/components/ui/logout-alert.tsx
+++ b/src/client/components/ui/logout-alert.tsx
@@ -17,6 +17,14 @@ interface LogoutAlertProps {
   onOpenChange: (open: boolean) => void;
 }
 
+/**
+ * Renders a confirmation dialog for logging out, handling the logout process and user feedback.
+ *
+ * Displays a modal asking the user to confirm logout. On confirmation, attempts to log out via an API call, shows a toast notification with the result, and navigates to the login page on success.
+ *
+ * @param open - Whether the dialog is visible.
+ * @param onOpenChange - Callback to update the dialog's open state.
+ */
 export function LogoutAlert({ open, onOpenChange }: LogoutAlertProps) {
   const navigate = useNavigate();
   const { toast } = useToast();
@@ -32,15 +40,22 @@ export function LogoutAlert({ open, onOpenChange }: LogoutAlertProps) {
         body: JSON.stringify({}),
       });
       
-      if (response.ok) {
+      const data = await response.json();
+      
+      if (response.ok && data.success) {
         toast({
-          description: 'Successfully logged out',
+          description: data.message || 'Successfully logged out',
           variant: 'default',
         });
         navigate('/app/login');
       } else {
+        // Close the logout dialog
+        onOpenChange(false);
+        
+        // Show the error message from the server
         toast({
-          description: 'Failed to log out. Please try again.',
+          title: "Logout unavailable",
+          description: data.message || 'Failed to log out. Please try again.',
           variant: 'destructive',
         });
       }
diff --git a/src/plugins/external/env.ts b/src/plugins/external/env.ts
index 00e1cd789..80489787e 100644
--- a/src/plugins/external/env.ts
+++ b/src/plugins/external/env.ts
@@ -47,6 +47,11 @@ const schema = {
       type: 'number',
       default: 500,
     },
+    authenticationMethod: {
+      type: 'string',
+      enum: ['required', 'requiredExceptLocal', 'disabled'],
+      default: 'required',
+    },
     syncIntervalSeconds: {
       type: 'number',
       default: 10,
diff --git a/src/routes/autohooks.ts b/src/routes/autohooks.ts
index 6c635ebfb..b149a00b8 100644
--- a/src/routes/autohooks.ts
+++ b/src/routes/autohooks.ts
@@ -1,4 +1,5 @@
 import type { FastifyInstance } from 'fastify'
+import { isLocalIpAddress } from '@utils/ip.js'
 
 export default async function (fastify: FastifyInstance) {
   fastify.addHook('onRequest', async (request, reply) => {
@@ -8,10 +9,37 @@ export default async function (fastify: FastifyInstance) {
       '/v1/notifications/webhook',
     ]
 
+    // Skip authentication for public paths
     if (publicPaths.some((path) => request.url.startsWith(path))) {
       return
     }
 
+    // Check authentication method from configuration
+    const authMethod = fastify.config.authenticationMethod
+
+    // Completely disabled authentication
+    if (authMethod === 'disabled') {
+      fastify.log.debug(
+        { url: request.url },
+        'Authentication disabled globally',
+      )
+      return
+    }
+
+    // Disabled for local addresses
+    if (authMethod === 'requiredExceptLocal') {
+      const clientIp = request.ip
+      if (isLocalIpAddress(clientIp)) {
+        // Local address with auth bypass enabled - skip authentication check
+        fastify.log.debug(
+          { ip: clientIp, url: request.url },
+          'Bypassing authentication for local address',
+        )
+        return
+      }
+    }
+
+    // Regular authentication check for all other cases
     if (!request.session.user) {
       reply.unauthorized('You must be authenticated to access this route.')
     }
diff --git a/src/routes/v1/users/logout.ts b/src/routes/v1/users/logout.ts
index f0f8cb133..e0c344304 100644
--- a/src/routes/v1/users/logout.ts
+++ b/src/routes/v1/users/logout.ts
@@ -1,6 +1,7 @@
 import type { FastifyPluginAsync } from 'fastify'
 import type { z } from 'zod'
 import { LogoutBodySchema, LogoutResponseSchema } from '@schemas/auth/logout.js'
+import { isLocalIpAddress } from '@utils/ip.js'
 
 const plugin: FastifyPluginAsync = async (fastify) => {
   fastify.post<{
@@ -13,13 +14,33 @@ const plugin: FastifyPluginAsync = async (fastify) => {
         body: LogoutBodySchema,
         response: {
           200: LogoutResponseSchema,
+          400: LogoutResponseSchema,
         },
         tags: ['Authentication'],
       },
     },
     async (request, reply) => {
       try {
+        // Check authentication method setting
+        const authMethod = fastify.config.authenticationMethod
+        const isAuthDisabled = authMethod === 'disabled'
+        const isLocalBypass =
+          authMethod === 'requiredExceptLocal' && isLocalIpAddress(request.ip)
+
+        // If auth is disabled globally or for local addresses
+        if (isAuthDisabled || isLocalBypass) {
+          // Return 400 Bad Request to prevent the client from treating this as a successful logout
+          reply.status(400)
+          return {
+            success: false,
+            message:
+              'Logout not available: Authentication is disabled for your IP address.',
+          }
+        }
+
+        // Normal logout flow
         if (!request.session.user) {
+          reply.status(400)
           return {
             success: false,
             message: 'No active session found.',
diff --git a/src/types/config.types.ts b/src/types/config.types.ts
index 8b5a96a77..613f34347 100644
--- a/src/types/config.types.ts
+++ b/src/types/config.types.ts
@@ -44,6 +44,7 @@ export interface Config {
   cookieSecured: boolean
   logLevel: LogLevel
   closeGraceDelay: number
+  authenticationMethod: 'required' | 'requiredExceptLocal' | 'disabled'
   rateLimitMax: number
   syncIntervalSeconds: number
   queueProcessDelaySeconds: number
diff --git a/src/utils/ip.ts b/src/utils/ip.ts
new file mode 100644
index 000000000..887700985
--- /dev/null
+++ b/src/utils/ip.ts
@@ -0,0 +1,88 @@
+/**
+ * Determines whether the given IP address is a local or private address.
+ *
+ * Checks if the input IP belongs to any recognized local or private ranges, including IPv4 private networks, IPv6 unique local and link-local addresses, localhost, and IPv4-mapped IPv6 addresses.
+ *
+ * @param ip - The IP address to check.
+ * @returns `true` if the IP address is local or private; otherwise, `false`.
+ */
+export function isLocalIpAddress(ip: string): boolean {
+  // Handle null, undefined or empty inputs
+  if (!ip) {
+    return false
+  }
+
+  // Trim any whitespace
+  const cleanIp = ip.trim()
+
+  // Handle empty string after trimming
+  if (cleanIp.length === 0) {
+    return false
+  }
+
+  // Localhost check
+  if (cleanIp === '127.0.0.1' || cleanIp === '::1' || cleanIp === 'localhost') {
+    return true
+  }
+
+  // IPv4-mapped IPv6 addresses
+  if (cleanIp.startsWith('::ffff:')) {
+    const ipv4Part = cleanIp.substring(7)
+    // Direct IPv4 check to avoid recursion
+    return /^(127\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|192\.168\.|169\.254\.)/.test(
+      ipv4Part,
+    )
+  }
+
+  // IPv4 private ranges
+  if (cleanIp.includes('.')) {
+    const parts = cleanIp.split('.').map(Number)
+
+    // Validate it's a properly formatted IPv4 address
+    if (
+      parts.length !== 4 ||
+      parts.some((part) => Number.isNaN(part) || part < 0 || part > 255)
+    ) {
+      return false
+    }
+
+    // 10.0.0.0/8
+    if (parts[0] === 10) {
+      return true
+    }
+
+    // 172.16.0.0/12
+    if (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) {
+      return true
+    }
+
+    // 192.168.0.0/16
+    if (parts[0] === 192 && parts[1] === 168) {
+      return true
+    }
+
+    // 169.254.0.0/16 (link-local)
+    if (parts[0] === 169 && parts[1] === 254) {
+      return true
+    }
+
+    // 127.0.0.0/8 (localhost)
+    if (parts[0] === 127) {
+      return true
+    }
+  }
+
+  // IPv6 ULA (Unique Local Address) fc00::/7 - check for proper hex format
+  const fcFdPattern = /^f[cd][0-9a-f]{2}:([0-9a-f]{0,4}:){0,7}[0-9a-f]{0,4}$/i
+  if (fcFdPattern.test(cleanIp)) {
+    return true
+  }
+
+  // IPv6 link-local fe80::/10 - check for proper hex format
+  const fe80Pattern = /^fe80:([0-9a-f]{0,4}:){0,7}[0-9a-f]{0,4}$/i
+  if (fe80Pattern.test(cleanIp)) {
+    return true
+  }
+
+  return false
+}
diff --git a/src/utils/session.ts b/src/utils/session.ts
new file mode 100644
index 000000000..a31d92eb7
--- /dev/null
+++ b/src/utils/session.ts
@@ -0,0 +1,18 @@
+import type { FastifyRequest } from 'fastify'
+
+/**
+ * Assigns a temporary admin user to the session for authentication bypass scenarios.
+ *
+ * @remark
+ * Intended for use when authentication is disabled globally or for local IP addresses. The session user is set with fixed admin credentials.
+ *
+ * @param request - The Fastify request object with session support.
+ */
+export function createTemporaryAdminSession(request: FastifyRequest): void {
+  request.session.user = {
+    id: 0,
+    email: 'auth-bypass@local',
+    username: 'auth-bypass',
+    role: 'admin',
+  }
+}


Reviews:
user: login: coderabbitai[bot]
body: **Actionable comments posted: 1**

<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>

<details>
<summary>src/utils/ip.ts (1)</summary><blockquote>

`1-49`: **Well-documented IP checking implementation, but has a few edge cases**

The function is comprehensive and handles many IP address formats, with excellent documentation of the covered ranges. However, there are two issues:

1. The IPv6 check at line 44 will match any string starting with 'fc', 'fd', or 'fe80:' without validating it's a properly formatted IPv6 address.
2. The code doesn't handle IPv4-mapped IPv6 addresses (e.g., '::ffff:192.168.1.1').


Consider enhancing with better IPv6 validation and support for IPv4-mapped IPv6 addresses:

```diff
 // IPv6 simple checks
-if (ip.startsWith('fc') || ip.startsWith('fd') || ip.startsWith('fe80:')) {
+// Check for IPv4-mapped IPv6 addresses
+if (ip.startsWith('::ffff:')) {
+  const ipv4Part = ip.substring(7);
+  return isLocalIpAddress(ipv4Part); // Recursively check the IPv4 part
+}
+
+// Check for proper IPv6 ULA and link-local formats
+if (/^fc[0-9a-f]{2}:/i.test(ip) || /^fd[0-9a-f]{2}:/i.test(ip) || /^fe80:/i.test(ip)) {
   return true
 }
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 293b5e2533ec78827149ab790c0367764d1ce548 and e139a0fd72542f0eed7d16f1e1820a801b0aaaed.

</details>

<details>
<summary>📒 Files selected for processing (7)</summary>

* `src/app.ts` (4 hunks)
* `src/client/components/ui/logout-alert.tsx` (1 hunks)
* `src/plugins/external/env.ts` (1 hunks)
* `src/routes/autohooks.ts` (2 hunks)
* `src/routes/v1/users/logout.ts` (2 hunks)
* `src/types/config.types.ts` (1 hunks)
* `src/utils/ip.ts` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (2)</summary>

<details>
<summary>src/routes/autohooks.ts (1)</summary><blockquote>

<details>
<summary>src/utils/ip.ts (1)</summary>

* `isLocalIpAddress` (12-49)

</details>

</blockquote></details>
<details>
<summary>src/routes/v1/users/logout.ts (2)</summary><blockquote>

<details>
<summary>src/schemas/auth/logout.ts (1)</summary>

* `LogoutResponseSchema` (5-8)

</details>
<details>
<summary>src/utils/ip.ts (1)</summary>

* `isLocalIpAddress` (12-49)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>🔇 Additional comments (16)</summary><blockquote>

<details>
<summary>src/plugins/external/env.ts (1)</summary>

`50-54`: **New configuration property looks well implemented**

The `authenticationMethod` property is properly defined with appropriate type constraints and a reasonable default value of 'required'. The enum values are descriptive and follow the established pattern for config properties in this file.

</details>
<details>
<summary>src/types/config.types.ts (1)</summary>

`47-47`: **Type definition correctly implements the authentication method options**

The addition of the `authenticationMethod` property to the Config interface is clear and consistent with the schema defined in env.ts. The string literal union type properly constrains the allowed values.

</details>
<details>
<summary>src/client/components/ui/logout-alert.tsx (2)</summary>

`35-40`: **Improved response handling for logout**

The changes correctly parse the JSON response and check both HTTP status and the success field from the response body before considering the logout successful. The toast message now uses the server-provided message when available.

---

`44-51`: **Good UX for logout failure cases**

The enhanced error handling properly closes the logout dialog and shows a clear error message to the user when logout is unavailable. This is important for the new authentication bypass feature where logout might be disabled.

</details>
<details>
<summary>src/routes/v1/users/logout.ts (4)</summary>

`4-4`: **Good addition of the IP utility import.**

This appropriately adds the dependency needed for the local IP address check logic.

---

`17-17`: **Well-defined schema update for the new 400 response.**

Good practice to document all possible response codes in the schema definition.

---

`24-39`: **Thorough implementation of authentication method handling.**

The code correctly implements the authentication bypass logic, preventing logout when authentication is disabled or bypassed for local IPs. This is a logical approach since logout doesn't make sense when no authentication is enforced.

The clear error message helps client applications understand why the logout operation isn't available.

---

`41-43`: **Clear separation of authentication flow paths.**

Good use of comments to separate the conditional logout logic from the normal flow. Using `.status(400)` instead of the previous approach maintains consistency in error handling.

</details>
<details>
<summary>src/routes/autohooks.ts (5)</summary>

`2-2`: **Appropriate import of the IP utility.**

This correctly imports the dependency needed for local IP address checking.

---

`12-15`: **Clear comment for public paths logic.**

Good practice to document the purpose of existing code in relation to the new authentication flow.

---

`17-27`: **Well-implemented global authentication bypass.**

The code correctly implements the disabled authentication mode with appropriate debug logging. This helps with local development and debugging scenarios.

---

`29-40`: **Comprehensive local IP bypass implementation.**

The code correctly implements the local IP address bypass logic with helpful debug logging that includes both the IP and requested URL for troubleshooting.

---

`42-43`: **Clear demarcation of the default authentication path.**

Good comment that explains the fallthrough case for the standard authentication requirement.

</details>
<details>
<summary>src/app.ts (3)</summary>

`7-7`: **Appropriate import of the IP utility.**

This correctly imports the dependency needed for local IP address checking.

---

`146-178`: **Comprehensive preHandler authentication logic.**

The code correctly implements authentication checks for both login/create-user pages and other app routes based on the configured authentication method.

---

`108-138`: <details>
<summary>❓ Verification inconclusive</summary>

**Well-implemented root route authentication bypass.**

This code correctly handles authentication based on the configured method and IP address. For disabled auth or local bypass scenarios, it creates a temporary admin session and redirects appropriately.

However, there's a potential security consideration with the temporary admin session.



Consider adding a clear comment that this behavior is intended for development/internal environments only, and consider creating a session with minimal privileges rather than full admin access:

```diff
// Create a temporary session
request.session.user = {
  id: 0,
  email: 'auth-bypass@local',
  username: 'auth-bypass',
-  role: 'admin',
+  role: 'auth-bypass', // Special role with minimal required privileges
}
```

Also, verify the security implications with:

---

🏁 Script executed:

```shell
#!/bin/bash
# Check for potential security controls around authentication method
rg -A 5 -B 5 "authenticationMethod.*=.*('disabled'|\"disabled\")" --glob "*.ts"
```

Length of output: 85

---

🏁 Script executed:

```shell
#!/bin/bash
# Locate where `authenticationMethod` is defined or initialized
rg -n "authenticationMethod" .
```

Length of output: 536

---



</details>

**Document and restrict temporary admin bypass**  

Add a clear comment that the “disabled” and “requiredExceptLocal” bypass is only for development or internal use, and scope the temporary session to a minimal-privilege role rather than full admin:

```diff
    // Create a temporary session (for dev/local bypass only)
    request.session.user = {
      id: 0,
      email: 'auth-bypass@local',
      username: 'auth-bypass',
-     role: 'admin',
+     role: 'auth-bypass', // minimal-privileges role for auth bypass
    }
```

Also ensure in your deployment/configuration that `authenticationMethod = 'disabled'` (or `'requiredExceptLocal'`) cannot be enabled in production without a deliberate override.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-26T06:28:07Z
user: login: jamcalli
state: COMMENTED
author_association: OWNER
submitted_at: 2025-04-26T06:38:53Z
user: login: coderabbitai[bot]
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-26T06:40:03Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 1**

<details>
<summary>🧹 Nitpick comments (3)</summary><blockquote>

<details>
<summary>src/utils/ip.ts (3)</summary><blockquote>

`9-34`: **Consider adding null/empty input handling**

The function handles various IP formats well, but could be more robust with explicit handling for null, undefined, or empty string inputs.


```diff
export function isLocalIpAddress(ip: string): boolean {
+  // Handle null, undefined or empty inputs
+  if (!ip) {
+    return false
+  }
+
  // Trim any whitespace
  const cleanIp = ip.trim()

+  // Handle empty string after trimming
+  if (cleanIp.length === 0) {
+    return false
+  }

  // Localhost check
  if (cleanIp === '127.0.0.1' || cleanIp === '::1' || cleanIp === 'localhost') {
    return true
  }
```

---

`62-71`: **Enhance IPv6 validation**

The current implementation checks for IPv6 local address prefixes but doesn't validate the full IPv6 format. Consider using a more comprehensive regex or a dedicated IP address validation library to ensure correct handling of all IPv6 format variations.


IPv6 addresses can have different representations (compressed zeros, IPv4-mapped notation, etc.). A more thorough validation would prevent false positives on malformed inputs that happen to start with the checked prefixes.

---

`18-22`: **Consider limiting recursion depth**

The recursive approach for IPv4-mapped IPv6 addresses is elegant, but consider adding a recursion limiter to prevent potential stack overflow with maliciously crafted inputs.


```diff
// IPv4-mapped IPv6 addresses
if (cleanIp.startsWith('::ffff:')) {
  const ipv4Part = cleanIp.substring(7)
-  return isLocalIpAddress(ipv4Part) // Recursively check the IPv4 part
+  // Direct IPv4 check to avoid recursion
+  return /^(127\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.|192\.168\.|169\.254\.)/.test(ipv4Part)
}
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yml**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 293b5e2533ec78827149ab790c0367764d1ce548 and be495b59486b8994998d53a76de3c0ebcdb0ff9b.

</details>

<details>
<summary>📒 Files selected for processing (8)</summary>

* `src/app.ts` (5 hunks)
* `src/client/components/ui/logout-alert.tsx` (2 hunks)
* `src/plugins/external/env.ts` (1 hunks)
* `src/routes/autohooks.ts` (2 hunks)
* `src/routes/v1/users/logout.ts` (2 hunks)
* `src/types/config.types.ts` (1 hunks)
* `src/utils/ip.ts` (1 hunks)
* `src/utils/session.ts` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (3)</summary>

<details>
<summary>src/routes/v1/users/logout.ts (2)</summary><blockquote>

<details>
<summary>src/schemas/auth/logout.ts (1)</summary>

* `LogoutResponseSchema` (5-8)

</details>
<details>
<summary>src/utils/ip.ts (1)</summary>

* `isLocalIpAddress` (9-74)

</details>

</blockquote></details>
<details>
<summary>src/routes/autohooks.ts (1)</summary><blockquote>

<details>
<summary>src/utils/ip.ts (1)</summary>

* `isLocalIpAddress` (9-74)

</details>

</blockquote></details>
<details>
<summary>src/app.ts (2)</summary><blockquote>

<details>
<summary>src/utils/ip.ts (1)</summary>

* `isLocalIpAddress` (9-74)

</details>
<details>
<summary>src/utils/session.ts (1)</summary>

* `createTemporaryAdminSession` (11-18)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>🔇 Additional comments (22)</summary><blockquote>

<details>
<summary>src/plugins/external/env.ts (1)</summary>

`50-54`: **Well-implemented authentication method configuration**

The addition of the `authenticationMethod` configuration property with three clear options (`'required'`, `'requiredExceptLocal'`, `'disabled'`) provides a flexible way to control authentication behavior. The default value of `'required'` is security-conscious, ensuring authentication is enforced unless explicitly configured otherwise.

</details>
<details>
<summary>src/utils/ip.ts (1)</summary>

`1-8`: **Well-documented utility function**

The JSDoc comments clearly describe the purpose and behavior of the function, making it easy for other developers to understand its usage.

</details>
<details>
<summary>src/types/config.types.ts (1)</summary>

`47-47`: **Type definition aligns with schema**

The union type for `authenticationMethod` correctly matches the enum values defined in the environment schema, providing proper type safety.

</details>
<details>
<summary>src/utils/session.ts (1)</summary>

`3-10`: **Good documentation of security implications**

The JSDoc comments clearly indicate this function is for authentication bypass scenarios, which helps prevent misuse.

</details>
<details>
<summary>src/client/components/ui/logout-alert.tsx (4)</summary>

`20-27`: **Well-documented component with clear JSDoc.**

The added JSDoc documentation provides clear information about the component's purpose, behavior, and parameters, which improves code maintainability and helps other developers understand how to use this component.

---

`43-45`: **Improved response handling with proper JSON parsing.**

The changes correctly parse the JSON response body before checking the response status, and now require both `response.ok` and `data.success` to be true, which aligns with the backend changes in the logout route.

---

`47-48`: **Enhanced success message handling.**

Using the server-provided message with a fallback to the default text improves the user experience by displaying more specific information.

---

`52-59`: **Improved error handling with explicit dialog closure.**

The changes properly handle the error case by:
1. Explicitly closing the logout dialog
2. Showing a clear "Logout unavailable" title
3. Using the server's error message when available

This provides better feedback to users when logout isn't available due to disabled authentication.

</details>
<details>
<summary>src/routes/v1/users/logout.ts (4)</summary>

`4-4`: **Appropriate utility import for IP detection.**

The import of the `isLocalIpAddress` utility is necessary for the new authentication bypass logic.

---

`17-17`: **Properly updated response schema for error handling.**

Adding the 400 status code to the response schema ensures proper API documentation and client expectations for error responses.

---

`24-39`: **Well-structured authentication method check with clear conditions.**

This implementation correctly:
1. Checks the global authentication method setting
2. Evaluates if authentication is disabled or bypassed for local IPs
3. Returns an appropriate 400 status with a clear message when logout is unavailable
4. Prevents users from logging out when authentication is disabled, maintaining consistency

The code is well-commented and the variables have descriptive names that make the logic easy to follow.

---

`43-43`: **Improved HTTP status code for missing session.**

Changing the response for "no active session" to HTTP 400 is more semantically correct as it represents a client error condition.

</details>
<details>
<summary>src/routes/autohooks.ts (4)</summary>

`2-2`: **Appropriate utility import for IP detection.**

The import of the `isLocalIpAddress` utility is necessary for the local IP authentication bypass feature.

---

`17-27`: **Well-implemented global authentication bypass with proper logging.**

This code correctly:
1. Retrieves the authentication method from configuration
2. Handles the 'disabled' authentication mode by completely bypassing authentication
3. Includes detailed debug logging with relevant context

The implementation follows the principle of early returns for clearer control flow.

---

`29-40`: **Well-implemented local IP authentication bypass with proper validation.**

This code correctly:
1. Handles the 'requiredExceptLocal' authentication mode
2. Extracts and validates the client IP
3. Bypasses authentication only for local addresses
4. Includes detailed debug logging with both IP and URL context

The implementation properly leverages the `isLocalIpAddress` utility function to determine if the client qualifies for authentication bypass.

---

`42-42`: **Clear comment for the default authentication case.**

Adding a comment for the regular authentication check helps clarify that this is the default path when other conditions don't apply.

</details>
<details>
<summary>src/app.ts (6)</summary>

`7-8`: **Appropriate utility imports for authentication bypass feature.**

The imports for IP detection and temporary session creation are necessary for implementing the authentication bypass functionality consistently.

---

`19-26`: **Comprehensive JSDoc with clear explanation of authentication modes.**

The added JSDoc documentation:
1. Clearly explains the module's purpose and functionality
2. Describes the authentication bypass options
3. Documents the temporary admin session behavior
4. Includes relevant implementation details

This level of documentation significantly improves code maintainability.

---

`122-140`: **Well-implemented authentication bypass in root route.**

This implementation correctly:
1. Checks the authentication method configuration
2. Evaluates local IP bypass conditions
3. Creates temporary admin sessions when appropriate using the utility function
4. Maintains proper redirection logic based on user existence
5. Preserves the original behavior when authentication is required

The code is well-structured with clear variable names and logical flow.

---

`151-156`: **Consistent authentication method checking in app route prehandler.**

The implementation reuses the same pattern as the root route for determining authentication requirements, which ensures consistency across the application.

---

`162-162`: **Updated conditional redirect for login and create-user pages.**

The condition now properly includes authentication bypass scenarios (disabled or local bypass) in addition to the existing session check.

---

`181-196`: **Well-implemented authentication bypass for app pages.**

This implementation correctly:
1. Handles the case where no session exists
2. Creates a temporary admin session when authentication is bypassed
3. Redirects appropriately based on user existence
4. Includes clear comments explaining each condition
5. Preserves the original redirection logic when authentication is required

The temporary session creation uses the extracted utility function, ensuring consistency with other parts of the codebase.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-26T07:00:51Z
user: login: jamcalli
state: COMMENTED
author_association: OWNER
submitted_at: 2025-04-26T07:06:19Z
user: login: coderabbitai[bot]
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-26T07:06:53Z

Review comments:
diff_hunk: @@ -137,8 +171,29 @@ export default async function serviceApp(
           return
         }
 
+        // For all other app pages
         if (!request.session.user) {
-          return reply.redirect('/app/login')
+          // If auth is disabled or this is a local connection with local bypass
+          if (isAuthDisabled || isLocalBypass) {
+            // Create a temporary session for the current request only
+            const hasUsers = await fastify.db.hasAdminUsers()
+
+            if (hasUsers) {
+              // Use a temporary session
+              request.session.user = {
+                id: 0,
+                email: 'auth-bypass@local',
+                username: 'auth-bypass',
+                role: 'admin',
+              }
+            } else {
+              // No users exist yet, redirect to create user
+              return reply.redirect('/app/create-user')
+            }
+          } else {
+            // Regular auth required - redirect to login
+            return reply.redirect('/app/login')
+          }
         }
path: src/app.ts
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Code duplication in temporary session creation.**

The temporary session creation logic is duplicated from the root route handler. This could lead to maintenance issues if one implementation is updated but not the other.


Consider extracting the temporary session creation into a utility function to ensure consistency:

```diff
+ // Add to a utility file, e.g., src/utils/auth.js
+ export function createTemporaryAdminSession(request) {
+   request.session.user = {
+     id: 0,
+     email: 'auth-bypass@local',
+     username: 'auth-bypass',
+     role: 'admin',
+   }
+ }

// Then use in both places:
- request.session.user = {
-   id: 0,
-   email: 'auth-bypass@local',
-   username: 'auth-bypass',
-   role: 'admin',
- }
+ createTemporaryAdminSession(request);
```


> Committable suggestion skipped: line range outside the PR's diff.

<!-- This is an auto-generated reply by CodeRabbit -->

✅ Addressed in commits e139a0f to 822c25f

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-04-26T06:28:06Z
author_association: CONTRIBUTOR
diff_hunk: @@ -137,8 +171,29 @@ export default async function serviceApp(
           return
         }
 
+        // For all other app pages
         if (!request.session.user) {
-          return reply.redirect('/app/login')
+          // If auth is disabled or this is a local connection with local bypass
+          if (isAuthDisabled || isLocalBypass) {
+            // Create a temporary session for the current request only
+            const hasUsers = await fastify.db.hasAdminUsers()
+
+            if (hasUsers) {
+              // Use a temporary session
+              request.session.user = {
+                id: 0,
+                email: 'auth-bypass@local',
+                username: 'auth-bypass',
+                role: 'admin',
+              }
+            } else {
+              // No users exist yet, redirect to create user
+              return reply.redirect('/app/create-user')
+            }
+          } else {
+            // Regular auth required - redirect to login
+            return reply.redirect('/app/login')
+          }
         }
path: src/app.ts
user: login: jamcalli
body: refactored accordingly. Please review. 
created_at: 2025-04-26T06:38:53Z
author_association: OWNER
diff_hunk: @@ -137,8 +171,29 @@ export default async function serviceApp(
           return
         }
 
+        // For all other app pages
         if (!request.session.user) {
-          return reply.redirect('/app/login')
+          // If auth is disabled or this is a local connection with local bypass
+          if (isAuthDisabled || isLocalBypass) {
+            // Create a temporary session for the current request only
+            const hasUsers = await fastify.db.hasAdminUsers()
+
+            if (hasUsers) {
+              // Use a temporary session
+              request.session.user = {
+                id: 0,
+                email: 'auth-bypass@local',
+                username: 'auth-bypass',
+                role: 'admin',
+              }
+            } else {
+              // No users exist yet, redirect to create user
+              return reply.redirect('/app/create-user')
+            }
+          } else {
+            // Regular auth required - redirect to login
+            return reply.redirect('/app/login')
+          }
         }
path: src/app.ts
user: login: coderabbitai[bot]
body: <details>
<summary>🧩 Analysis chain</summary>

The code has been refactored according to my suggestion to extract the temporary session creation logic into a utility function. Let's verify the implementation.

---

🏁 Script executed:
```
#!/bin/bash
# Check if the utility function exists in the session utility file
echo "Checking for createTemporaryAdminSession function in session utility file:"
cat src/utils/session.js

echo -e "\n\nChecking how the function is used in app.ts:"
cat src/app.ts | grep -A 3 -B 3 "createTemporaryAdminSession"
```

Length of output: 1100

---



</details>

@jamcalli I've reviewed the refactoring, and it looks great! You've successfully extracted the temporary session creation logic into a utility function and are using it consistently in both locations. This eliminates the code duplication and will make future maintenance easier.

The implementation:
1. Creates a reusable `createTemporaryAdminSession` function 
2. Imports it properly at the top of app.ts
3. Calls it in both places where you previously had duplicated code

This is exactly what I suggested and follows good software engineering practices. Nice work!



---

<details>
<summary>🧬 Code Graph Analysis Results</summary>

### Relevant snippets from `src/utils/session.ts` (lines 9-16)
```ts
export function createTemporaryAdminSession(request: FastifyRequest): void {
  request.session.user = {
    id: 0,
    email: 'auth-bypass@local',
    username: 'auth-bypass',
    role: 'admin',
  }
}
```

### Relevant snippets from `src/utils/ip.ts` (lines 14-79)
```ts
export function isLocalIpAddress(ip: string): boolean {
  // Trim any whitespace
  const cleanIp = ip.trim()

  // Localhost check
  if (cleanIp === '127.0.0.1' || cleanIp === '::1' || cleanIp === 'localhost') {
    return true
  }

  // IPv4-mapped IPv6 addresses
  if (cleanIp.startsWith('::ffff:')) {
    const ipv4Part = cleanIp.substring(7)
    return isLocalIpAddress(ipv4Part) // Recursively check the IPv4 part
  }

  // IPv4 private ranges
  if (cleanIp.includes('.')) {
    const parts = cleanIp.split('.').map(Number)

    // Validate it's a properly formatted IPv4 address
    if (
      parts.length !== 4 ||
      parts.some((part) => Number.isNaN(part) || part < 0 || part > 255)
    ) {
      return false
    }

    // 10.0.0.0/8
    if (parts[0] === 10) {
      return true
    }

    // 172.16.0.0/12
    if (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) {
      return true
    }

    // 192.168.0.0/16
    if (parts[0] === 192 && parts[1] === 168) {
      return true
    }

    // 169.254.0.0/16 (link-local)
    if (parts[0] === 169 && parts[1] === 254) {
      return true
    }

    // 127.0.0.0/8 (localhost)
    if (parts[0] === 127) {
      return true
    }
  }

  // IPv6 checks with proper format validation
  // Check for ULA (Unique Local Address) fc00::/7
  if (/^fc[0-9a-f]{2}:/i.test(cleanIp) || /^fd[0-9a-f]{2}:/i.test(cleanIp)) {
    return true
  }

  // IPv6 link-local fe80::/10
  if (/^fe80:/i.test(cleanIp)) {
    return true
  }

  return false
}
```

### Possibly relevant snippet from `src/plugins/custom/scrypt.ts` (lines 5-8)
```ts
export interface FastifyInstance {
    hash: typeof scryptHash
    compare: typeof compare
  }
```

This snippet shows an interface extension for FastifyInstance adding `hash` and `compare` methods related to scrypt hashing, which might be relevant if authentication or password handling is involved in the app.

</details>

---

<!-- This is an auto-generated comment: tweet message by coderabbit.ai -->

If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Avoid%20duplicated%20session%20creation%20code%20by%20extracting%20it%20into%20a%20utility%20function!%20Keeps%20your%20code%20DRY%20and%20easier%20to%20maintain.%20Try%20%40coderabbitai%20for%20smart%20refactor%20tips!%20%F0%9F%9B%A0%EF%B8%8F%E2%9C%A8&url=https%3A%2F%2Fgithub.com%2Fjamcalli%2FPulsarr%2Fpull%2F116%23discussion_r2061193801)?

Thank you for using CodeRabbit!

<!-- end of auto-generated comment: tweet message by coderabbit.ai -->




<!-- <agentComponentType>chat-answer</agentComponentType> -->

<!-- <rawResChunk><answer><details>
<summary>🧩 Analysis chain</summary>

The code has been refactored according to my suggestion to extract the temporary session creation logic into a utility function. Let's verify the implementation.

---

🏁 Script executed:
```
#!/bin/bash
# Check if the utility function exists in the session utility file
echo "Checking for createTemporaryAdminSession function in session utility file:"
cat src/utils/session.js

echo -e "\n\nChecking how the function is used in app.ts:"
cat src/app.ts | grep -A 3 -B 3 "createTemporaryAdminSession"
```

Length of output: 1100

---



</details>

@jamcalli I've reviewed the refactoring, and it looks great! You've successfully extracted the temporary session creation logic into a utility function and are using it consistently in both locations. This eliminates the code duplication and will make future maintenance easier.

The implementation:
1. Creates a reusable `createTemporaryAdminSession` function 
2. Imports it properly at the top of app.ts
3. Calls it in both places where you previously had duplicated code

This is exactly what I suggested and follows good software engineering practices. Nice work!



---

<details>
<summary>🧬 Code Graph Analysis Results</summary>

### Relevant snippets from `src/utils/session.ts` (lines 9-16)
```ts
export function createTemporaryAdminSession(request: FastifyRequest): void {
  request.session.user = {
    id: 0,
    email: 'auth-bypass@local',
    username: 'auth-bypass',
    role: 'admin',
  }
}
```

### Relevant snippets from `src/utils/ip.ts` (lines 14-79)
```ts
export function isLocalIpAddress(ip: string): boolean {
  // Trim any whitespace
  const cleanIp = ip.trim()

  // Localhost check
  if (cleanIp === '127.0.0.1' || cleanIp === '::1' || cleanIp === 'localhost') {
    return true
  }

  // IPv4-mapped IPv6 addresses
  if (cleanIp.startsWith('::ffff:')) {
    const ipv4Part = cleanIp.substring(7)
    return isLocalIpAddress(ipv4Part) // Recursively check the IPv4 part
  }

  // IPv4 private ranges
  if (cleanIp.includes('.')) {
    const parts = cleanIp.split('.').map(Number)

    // Validate it's a properly formatted IPv4 address
    if (
      parts.length !== 4 ||
      parts.some((part) => Number.isNaN(part) || part < 0 || part > 255)
    ) {
      return false
    }

    // 10.0.0.0/8
    if (parts[0] === 10) {
      return true
    }

    // 172.16.0.0/12
    if (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) {
      return true
    }

    // 192.168.0.0/16
    if (parts[0] === 192 && parts[1] === 168) {
      return true
    }

    // 169.254.0.0/16 (link-local)
    if (parts[0] === 169 && parts[1] === 254) {
      return true
    }

    // 127.0.0.0/8 (localhost)
    if (parts[0] === 127) {
      return true
    }
  }

  // IPv6 checks with proper format validation
  // Check for ULA (Unique Local Address) fc00::/7
  if (/^fc[0-9a-f]{2}:/i.test(cleanIp) || /^fd[0-9a-f]{2}:/i.test(cleanIp)) {
    return true
  }

  // IPv6 link-local fe80::/10
  if (/^fe80:/i.test(cleanIp)) {
    return true
  }

  return false
}
```

### Possibly relevant snippet from `src/plugins/custom/scrypt.ts` (lines 5-8)
```ts
export interface FastifyInstance {
    hash: typeof scryptHash
    compare: typeof compare
  }
```

This snippet shows an interface extension for FastifyInstance adding `hash` and `compare` methods related to scrypt hashing, which might be relevant if authentication or password handling is involved in the app.

</details>

---

&lt;!-- This is an auto-generated comment: tweet message by coderabbit.ai --&gt;

If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Avoid%20duplicated%20session%20creation%20code%20by%20extracting%20it%20into%20a%20utility%20function!%20Keeps%20your%20code%20DRY%20and%20easier%20to%20maintain.%20Try%20%40coderabbitai%20for%20smart%20refactor%20tips!%20%F0%9F%9B%A0%EF%B8%8F%E2%9C%A8&url=https%3A%2F%2Fgithub.com%2Fjamcalli%2FPulsarr%2Fpull%2F116%23discussion_r2061193801)?

Thank you for using CodeRabbit!

&lt;!-- end of auto-generated comment: tweet message by coderabbit.ai --&gt;

</answer></rawResChunk> -->

<!-- This is an auto-generated reply by CodeRabbit -->
created_at: 2025-04-26T06:40:03Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,18 @@
+import type { FastifyRequest } from 'fastify'
+
+/**
+ * Assigns a temporary admin user to the session for authentication bypass scenarios.
+ *
+ * @remark
+ * Intended for use when authentication is disabled globally or for local IP addresses. The session user is set with fixed admin credentials.
+ *
+ * @param request - The Fastify request object with session support.
+ */
+export function createTemporaryAdminSession(request: FastifyRequest): void {
+  request.session.user = {
+    id: 0,
+    email: 'auth-bypass@local',
+    username: 'auth-bypass',
+    role: 'admin',
+  }
+}
path: src/utils/session.ts
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Consider additional security measures**

While the implementation is clean, creating admin sessions has security implications. Consider these enhancements:
1. Add session expiration or time limits
2. Include logging when temporary sessions are created
3. Consider using a more restrictive role than full admin if possible
4. Add a unique identifier in the session to clearly mark it as temporary


```diff
export function createTemporaryAdminSession(request: FastifyRequest): void {
+  // Log temporary session creation with client IP
+  request.log.info(`Creating temporary admin session for IP: ${request.ip}`);
+  
  request.session.user = {
    id: 0,
    email: 'auth-bypass@local',
    username: 'auth-bypass',
    role: 'admin',
+    isTemporary: true,
+    createdAt: new Date().toISOString()
  }
+  
+  // Set session to expire after 24 hours
+  request.session.expires = new Date(Date.now() + 24 * 60 * 60 * 1000);
}
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

`````suggestion
export function createTemporaryAdminSession(request: FastifyRequest): void {
  // Log temporary session creation with client IP
  request.log.info(`Creating temporary admin session for IP: ${request.ip}`);

  request.session.user = {
    id: 0,
    email: 'auth-bypass@local',
    username: 'auth-bypass',
    role: 'admin',
    isTemporary: true,
    createdAt: new Date().toISOString()
  }

  // Set session to expire after 24 hours
  request.session.expires = new Date(Date.now() + 24 * 60 * 60 * 1000);
}
`````

</details>

<!-- suggestion_end -->

<!-- This is an auto-generated reply by CodeRabbit -->
created_at: 2025-04-26T07:00:50Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,18 @@
+import type { FastifyRequest } from 'fastify'
+
+/**
+ * Assigns a temporary admin user to the session for authentication bypass scenarios.
+ *
+ * @remark
+ * Intended for use when authentication is disabled globally or for local IP addresses. The session user is set with fixed admin credentials.
+ *
+ * @param request - The Fastify request object with session support.
+ */
+export function createTemporaryAdminSession(request: FastifyRequest): void {
+  request.session.user = {
+    id: 0,
+    email: 'auth-bypass@local',
+    username: 'auth-bypass',
+    role: 'admin',
+  }
+}
path: src/utils/session.ts
user: login: jamcalli
body: While this does make sense, and under normal circumstances would be a valid concern, this is a self-hosted app. 

The fastify session store is in memory, and these settings require a container restart, so that admin session would be invalidated anyways. 
created_at: 2025-04-26T07:06:19Z
author_association: OWNER
diff_hunk: @@ -0,0 +1,18 @@
+import type { FastifyRequest } from 'fastify'
+
+/**
+ * Assigns a temporary admin user to the session for authentication bypass scenarios.
+ *
+ * @remark
+ * Intended for use when authentication is disabled globally or for local IP addresses. The session user is set with fixed admin credentials.
+ *
+ * @param request - The Fastify request object with session support.
+ */
+export function createTemporaryAdminSession(request: FastifyRequest): void {
+  request.session.user = {
+    id: 0,
+    email: 'auth-bypass@local',
+    username: 'auth-bypass',
+    role: 'admin',
+  }
+}
path: src/utils/session.ts
user: login: coderabbitai[bot]
body: @jamcalli Thank you for clarifying the application architecture. You're absolutely right - with an in-memory session store and configuration changes requiring container restarts, the security concerns I raised are mitigated by the design itself. Since the sessions don't persist across restarts and this is a self-hosted application, the additional safeguards would be redundant.

The implementation is appropriate for your use case. Thanks for providing this context about the application's session management approach.

---

<details>
<summary>✏️ Learnings added</summary>

```
Learnt from: jamcalli
PR: jamcalli/Pulsarr#116
File: src/utils/session.ts:11-18
Timestamp: 2025-04-26T07:06:52.138Z
Learning: Pulsarr is a self-hosted application with an in-memory Fastify session store. Sessions don't persist across container restarts, and configuration changes like authentication settings require a restart, inherently limiting session lifetimes.
```

> Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings).

</details>




<!-- <agentComponentType>chat-answer</agentComponentType> -->

<!-- <rawResChunk><answer>@jamcalli Thank you for clarifying the application architecture. You're absolutely right - with an in-memory session store and configuration changes requiring container restarts, the security concerns I raised are mitigated by the design itself. Since the sessions don't persist across restarts and this is a self-hosted application, the additional safeguards would be redundant.

The implementation is appropriate for your use case. Thanks for providing this context about the application's session management approach.

---

<details>
<summary>✏️ Learnings added</summary>

```
Learnt from: jamcalli
PR: jamcalli/Pulsarr#116
File: src/utils/session.ts:11-18
Timestamp: 2025-04-26T07:06:52.138Z
Learning: Pulsarr is a self-hosted application with an in-memory Fastify session store. Sessions don't persist across container restarts, and configuration changes like authentication settings require a restart, inherently limiting session lifetimes.
```

> Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings).

</details>

</answer></rawResChunk> -->

<!-- This is an auto-generated reply by CodeRabbit -->
created_at: 2025-04-26T07:06:53Z
author_association: CONTRIBUTOR

PR comments:
user: login: coderabbitai[bot]
created_at: 2025-04-26T06:25:53Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- This is an auto-generated comment: skip review by coderabbit.ai -->

> [!IMPORTANT]
> ## Review skipped
> 
> Auto reviews are disabled on base/target branches other than the default branch.
> 
> 
> 
> Please check the settings in the CodeRabbit UI or the `.coderabbit.yaml` file in this repository. To trigger a single review, invoke the `@coderabbitai review` command.
> 
> You can disable this status message by setting the `reviews.review_status` to `false` in the CodeRabbit configuration file.

<!-- end of auto-generated comment: skip review by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

The changes implement a configurable authentication bypass mechanism based on server settings and client IP address. A new configuration property, `authenticationMethod`, allows authentication to be required, disabled, or bypassed for local IPs. The application logic, including route handlers and authentication hooks, is updated to honor this setting—creating temporary admin sessions for local or unauthenticated access as appropriate. The logout endpoint now blocks logout attempts when authentication is disabled. A utility function for local IP detection is introduced, and client-side logout handling is improved to respond to new server-side logic.

## Changes

| File(s)                                                                 | Change Summary |
|-------------------------------------------------------------------------|----------------|
| `src/app.ts`                                                            | Updated root and `/app/*` route handlers to conditionally bypass authentication based on `authenticationMethod` and client IP, creating temporary admin sessions or redirecting as needed. |
| `src/routes/autohooks.ts`                                               | Enhanced authentication hook to check `authenticationMethod` and use local IP detection for conditional bypass of authentication. |
| `src/routes/v1/users/logout.ts`                                         | Modified logout handler to block logout when authentication is disabled or bypassed for local IPs; updated response schema for HTTP 400. |
| `src/client/components/ui/logout-alert.tsx`                             | Improved logout handler to parse JSON response, handle new logout failure cases, and update toast messages accordingly. |
| `src/plugins/external/env.ts`<br>`src/types/config.types.ts`            | Added `authenticationMethod` property to config/environment schema and type definitions. |
| `src/utils/ip.ts`                                                       | Introduced `isLocalIpAddress` utility for detecting local/private IP addresses. |
| `src/utils/session.ts`                                                  | Added utility function to create temporary admin sessions for authentication bypass scenarios. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant Server
    participant Auth
    participant DB

    Client->>Server: Request to /
    alt authenticationMethod is 'disabled' or (is 'requiredExceptLocal' and IP is local)
        Server->>DB: Check if admin users exist
        alt Admin users exist
            Server->>Auth: Create temp admin session
            Server-->>Client: Redirect to /app/dashboard
        else No users
            Server-->>Client: Redirect to /app/create-user
        end
    else authentication required
        Server->>DB: Check if users exist
        alt Users exist
            Server-->>Client: Redirect to /app/login
        else No users
            Server-->>Client: Redirect to /app/create-user
        end
    end
```

```mermaid
sequenceDiagram
    participant Client
    participant Server
    participant Auth

    Client->>Server: POST /api/v1/users/logout
    alt authenticationMethod is 'disabled' or (is 'requiredExceptLocal' and IP is local)
        Server-->>Client: 400 Logout unavailable (auth disabled)
    else Session exists
        Auth->>Server: Destroy session
        Server-->>Client: 200 Logout success
    else No session
        Server-->>Client: 400 Logout unavailable (no session)
    end
```

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAMxJqLnhmbki2DFC0PFh2eAZqeHwsNlxYRQUMWPgibCpxIvQMei98fN8ASStIOW40RERo7vlsREpI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xCsUGfFMON1VoDvOsUCDudoBoBRAKcQArY1UNN9MCB9MNM1XFMiMCDFMNMRdxfFO0B9OGdoBOMiNKCGeXO2kMC0DedtgNMCCELEL8c+Qqdqcaesx7y0DKePxFdAA -->

<!-- internal state end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=jamcalli/Pulsarr&utm_content=116):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: CONTRIBUTOR
user: login: jamcalli
created_at: 2025-04-26T06:26:08Z
body: @coderabbitai review
author_association: OWNER
user: login: coderabbitai[bot]
created_at: 2025-04-26T06:26:13Z
body: <!-- This is an auto-generated reply by CodeRabbit -->
<details>
<summary>✅ Actions performed</summary>

Review triggered.

> Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

</details>
author_association: CONTRIBUTOR
user: login: jamcalli
created_at: 2025-04-26T06:39:18Z
body: @coderabbitai summary
author_association: OWNER
user: login: coderabbitai[bot]
created_at: 2025-04-26T06:39:22Z
body: <!-- This is an auto-generated reply by CodeRabbit -->
<details>
<summary>✅ Actions performed</summary>

Summary regeneration triggered.

</details>
author_association: CONTRIBUTOR
user: login: jamcalli
created_at: 2025-04-26T06:39:34Z
body: @coderabbitai generate docstrings
author_association: OWNER
user: login: coderabbitai[bot]
created_at: 2025-04-26T06:39:39Z
body: <!-- This is an auto-generated reply by CodeRabbit -->
<details>
<summary>✅ Actions performed</summary>

Docstrings generation started.

</details>
author_association: CONTRIBUTOR
user: login: coderabbitai[bot]
created_at: 2025-04-26T06:41:02Z
body: > [!NOTE]
> Generated docstrings for this pull request at https://github.com/jamcalli/Pulsarr/pull/117
author_association: CONTRIBUTOR
user: login: jamcalli
created_at: 2025-04-26T06:59:07Z
body: @coderabbitai full review
author_association: OWNER
user: login: coderabbitai[bot]
created_at: 2025-04-26T06:59:11Z
body: <!-- This is an auto-generated reply by CodeRabbit -->
<details>
<summary>✅ Actions performed</summary>

Full review triggered.

</details>
author_association: CONTRIBUTOR