The Appium Device Farm currently:
- Manages devices for testing through a hub-node architecture
- Has a React-based frontend dashboard
- Uses Prisma with SQLite for data storage
- Has APIs for device management (block/unblock, status checking)
- Has no user authentication or team management system
- Admin portal for device allocation
- Team-based access control for devices
- Admin users can allocate/deallocate devices to teams
- Team members can only access devices allocated to their team
- Simple authentication (no OAuth)
- Admin user management (universal admin with password change capability)
- Local database storage for user credentials
We need to add new tables to the Prisma schema:
erDiagram
User {
String id PK
String username
String password
String role
DateTime createdAt
DateTime updatedAt
}
Team {
String id PK
String name
String description
DateTime createdAt
DateTime updatedAt
}
TeamMember {
String id PK
String userId FK
String teamId FK
DateTime createdAt
DateTime updatedAt
}
DeviceAllocation {
String id PK
String deviceUdid
String teamId FK
DateTime createdAt
DateTime updatedAt
}
User ||--o{ TeamMember : "has"
Team ||--o{ TeamMember : "has"
Team ||--o{ DeviceAllocation : "has"
- Create authentication middleware
- Implement login/logout functionality
- Add password hashing for security
- Create session management (JWT-based)
- Add role-based access control (admin vs. team member)
Create new API endpoints for:
-
User Management
- Create/update/delete users
- Change password
- List users
-
Team Management
- Create/update/delete teams
- Add/remove users from teams
- List teams and their members
-
Device Allocation
- Allocate devices to teams
- Deallocate devices from teams
- List device allocations
-
Authentication
- Login
- Logout
- Get current user
Add new pages and components to the dashboard:
-
Login Page
- Username/password form
- Error handling
-
Admin Dashboard
- User management section
- Team management section
- Device allocation section
-
Team Member Dashboard
- View allocated devices
- Access device details
-
Navigation Updates
- Add login/logout buttons
- Show different navigation based on user role
- Modify device access control to check team allocations
- Update device listing to filter based on team membership
- Integrate authentication with existing API endpoints
- Update Prisma schema with new models
- Create migration for the new tables
- Implement basic authentication system
- Create admin user management APIs
- Implement team CRUD operations
- Create team membership management
- Build team management UI
- Implement device allocation APIs
- Update device access control
- Create device allocation UI
- Integrate authentication with existing endpoints
- Update device listing to respect team allocations
- Test all functionality
- Fix any issues
sequenceDiagram
participant User
participant Frontend
participant AuthAPI
participant Database
User->>Frontend: Enter credentials
Frontend->>AuthAPI: POST /api/auth/login
AuthAPI->>Database: Verify credentials
Database-->>AuthAPI: User data
AuthAPI->>AuthAPI: Generate JWT
AuthAPI-->>Frontend: Return JWT token
Frontend->>Frontend: Store token in localStorage
Frontend-->>User: Redirect to dashboard
sequenceDiagram
participant Admin
participant Frontend
participant API
participant Database
Admin->>Frontend: Select devices and team
Frontend->>API: POST /api/device-allocation
API->>Database: Create allocation records
Database-->>API: Confirmation
API-->>Frontend: Success response
Frontend-->>Admin: Show success message
sequenceDiagram
participant User
participant Frontend
participant API
participant Database
User->>Frontend: Request device list
Frontend->>API: GET /api/device with JWT
API->>API: Extract user from JWT
API->>Database: Get user's teams
Database-->>API: Team IDs
API->>Database: Get devices allocated to teams
Database-->>API: Device list
API-->>Frontend: Filtered device list
Frontend-->>User: Display available devices
-
Prisma Schema Update
- Add User, Team, TeamMember, and DeviceAllocation models
-
New Backend Files
- Authentication middleware
- User controller
- Team controller
- Device allocation controller
- Authentication controller
-
New Frontend Files
- Login page
- Admin dashboard components
- Team management components
- Device allocation components
- Authentication service
-
Existing File Modifications
- Update device service to check team allocations
- Modify API routes to use authentication
- Update frontend device listing to respect allocations
- Password hashing using bcrypt
- JWT with appropriate expiration
- HTTPS for all communications
- Input validation and sanitization
- Protection against common attacks (CSRF, XSS)
This implementation plan provides a comprehensive approach to adding an admin portal with team-based device allocation to the Appium Device Farm. The solution is designed to be simple yet secure, without requiring OAuth integration.