Initial GuruConnect implementation - Phase 1 MVP
- Agent: DXGI/GDI screen capture, mouse/keyboard input, WebSocket transport - Server: Axum relay, session management, REST API - Dashboard: React viewer components with TypeScript - Protocol: Protobuf definitions for all message types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
61
server/src/auth/mod.rs
Normal file
61
server/src/auth/mod.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
//! Authentication module
|
||||
//!
|
||||
//! Handles JWT validation for dashboard users and API key
|
||||
//! validation for agents.
|
||||
|
||||
use axum::{
|
||||
extract::FromRequestParts,
|
||||
http::{request::Parts, StatusCode},
|
||||
};
|
||||
|
||||
/// Authenticated user from JWT
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AuthenticatedUser {
|
||||
pub user_id: String,
|
||||
pub email: String,
|
||||
pub roles: Vec<String>,
|
||||
}
|
||||
|
||||
/// Authenticated agent from API key
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AuthenticatedAgent {
|
||||
pub agent_id: String,
|
||||
pub org_id: String,
|
||||
}
|
||||
|
||||
/// Extract authenticated user from request (placeholder for MVP)
|
||||
#[axum::async_trait]
|
||||
impl<S> FromRequestParts<S> for AuthenticatedUser
|
||||
where
|
||||
S: Send + Sync,
|
||||
{
|
||||
type Rejection = (StatusCode, &'static str);
|
||||
|
||||
async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
|
||||
// TODO: Implement JWT validation
|
||||
// For MVP, accept any request
|
||||
|
||||
// Look for Authorization header
|
||||
let _auth_header = parts
|
||||
.headers
|
||||
.get("Authorization")
|
||||
.and_then(|v| v.to_str().ok());
|
||||
|
||||
// Placeholder - in production, validate JWT
|
||||
Ok(AuthenticatedUser {
|
||||
user_id: "mvp-user".to_string(),
|
||||
email: "mvp@example.com".to_string(),
|
||||
roles: vec!["admin".to_string()],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Validate an agent API key (placeholder for MVP)
|
||||
pub fn validate_agent_key(_api_key: &str) -> Option<AuthenticatedAgent> {
|
||||
// TODO: Implement actual API key validation
|
||||
// For MVP, accept any key
|
||||
Some(AuthenticatedAgent {
|
||||
agent_id: "mvp-agent".to_string(),
|
||||
org_id: "mvp-org".to_string(),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user