✅ Backend Implementation: - Add Azure AD JWT token validation middleware - Create hybrid authentication system supporting both Azure AD and password auth - Implement auto-provisioning for new Azure AD users - Add admin controls to toggle password authentication - Update all API routes to use hybrid authentication - Add database fields for authentication (password, lastLoginAt) - Create comprehensive auth routes with validation endpoints ✅ Frontend Implementation: - Install and configure Azure MSAL browser library - Create Azure AD authentication service with popup/redirect support - Build hybrid authentication service managing both auth methods - Update Login.vue with modern dual-authentication UI - Implement dynamic password auth toggle based on admin settings - Update App.vue for proper session management and validation - Modify API service to handle both token types ✅ Security Features: - Azure AD tenant validation (Oliver Agency) - Role-based access control with auto-admin assignment - JWT token validation for both auth methods - Automatic user provisioning with proper defaults - Session validation and automatic logout on token expiry ✅ Admin Features: - Toggle password authentication on/off - Manage users from both authentication methods - Full role and agent access control - Azure AD user auto-provisioning as regular users ✅ Configuration: - Azure AD: Tenant e519c2e6-bc6d-4fdf-8d9c-923c2f002385 - Client ID: 9079054c-9620-4757-a256-23413042f1ef - Development redirect URI support - Fallback password authentication for testing 🔧 Technical Stack: - Azure MSAL Browser & Node libraries - JWT token validation and hybrid middleware - Database schema updates with migrations - Vue.js integration with MSAL - Express.js hybrid authentication routes 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
No EOL
1.1 KiB
JavaScript
53 lines
No EOL
1.1 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/database');
|
|
|
|
const User = sequelize.define('User', {
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
email: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
unique: true,
|
|
validate: {
|
|
isEmail: true,
|
|
},
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
},
|
|
password: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
},
|
|
lastLoginAt: {
|
|
type: DataTypes.DATE,
|
|
allowNull: true,
|
|
},
|
|
preferences: {
|
|
type: DataTypes.JSONB,
|
|
defaultValue: {
|
|
theme: 'light',
|
|
notifications: true,
|
|
defaultAssistant: 'creator-bot-push-the-boundaries-of-technology',
|
|
role: 'user',
|
|
allowedAgents: null,
|
|
},
|
|
},
|
|
isActive: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: true,
|
|
},
|
|
}, {
|
|
tableName: 'users',
|
|
timestamps: true,
|
|
indexes: [
|
|
{ fields: ['email'] },
|
|
{ fields: ['isActive'] },
|
|
],
|
|
});
|
|
|
|
module.exports = User; |