Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ import dashboardRoutes from './routes/dashboard.js';
import { setupSwagger } from './swagger.js';
import { initializeCAIA } from './services/caia.js';

// Validate SESSION_SECRET in production
if (process.env.NODE_ENV === 'production' && !process.env.SESSION_SECRET) {
throw new Error('SESSION_SECRET environment variable is required in production');
// Validate SESSION_SECRET is set (required in all environments)
if (!process.env.SESSION_SECRET) {
throw new Error('SESSION_SECRET environment variable is required. Set it in your .env.local file.');
}

const sessionSecret = process.env.SESSION_SECRET || 'dev-only-secret-do-not-use-in-production';
const sessionSecret: string = process.env.SESSION_SECRET;

// CSRF protection setup
const { csrfSynchronisedProtection, generateToken } = csrfSync({
Expand Down
3 changes: 2 additions & 1 deletion api/src/db/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ async function seed() {
{ email: 'jack.brown@ship.local', name: 'Jack Brown' },
];

const passwordHash = await bcrypt.hash('admin123', 10);
const seedPassword = process.env.SEED_USER_PASSWORD || 'admin123';
const passwordHash = await bcrypt.hash(seedPassword, 10);
let usersCreated = 0;

for (const member of teamMembers) {
Expand Down
6 changes: 4 additions & 2 deletions e2e/fixtures/isolated-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const test = base.extend<
...process.env,
PORT: String(port),
DATABASE_URL: dbUrl,
SESSION_SECRET: process.env.SESSION_SECRET || 'test-session-secret',
CORS_ORIGIN: '*', // Allow any origin during tests
NODE_ENV: 'test',
// Prevent dotenv from overriding our DATABASE_URL
Expand Down Expand Up @@ -309,8 +310,9 @@ async function runMigrations(dbUrl: string): Promise<void> {
* - Issues with various states
*/
async function seedMinimalTestData(pool: Pool): Promise<void> {
// Hash the test password
const passwordHash = await bcrypt.hash('admin123', 10);
// Hash the test password (uses env var with test default)
const testPassword = process.env.TEST_USER_PASSWORD || 'admin123';
const passwordHash = await bcrypt.hash(testPassword, 10);

// Create workspace with sprint_start_date 3 months ago (matches full seed)
const threeMonthsAgo = new Date();
Expand Down
2 changes: 1 addition & 1 deletion web/src/hooks/useAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { api, UserInfo, Workspace } from '@/lib/api';
import { useWorkspace, WorkspaceWithRole } from '@/contexts/WorkspaceContext';

// Cache key for offline auth
const AUTH_CACHE_KEY = 'ship:auth-cache';
const AUTH_CACHE_KEY = import.meta.env.VITE_AUTH_CACHE_KEY || 'ship:auth-cache';

interface CachedAuth {
user: UserInfo;
Expand Down