Initialisation depot
This commit is contained in:
210
arti-api/auth-service/templates/dashboard.html
Normal file
210
arti-api/auth-service/templates/dashboard.html
Normal file
@@ -0,0 +1,210 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Dashboard - Artifactory</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 1rem 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.logout-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 2rem auto;
|
||||
padding: 0 2rem;
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 2rem;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: white;
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.card h3 {
|
||||
color: #333;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.card p {
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.api-link {
|
||||
display: inline-block;
|
||||
margin-top: 1rem;
|
||||
padding: 0.5rem 1rem;
|
||||
background: #667eea;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.api-link:hover {
|
||||
background: #5a6fd8;
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
border-radius: 6px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.alert-info {
|
||||
background-color: #d1ecf1;
|
||||
border: 1px solid #bee5eb;
|
||||
color: #0c5460;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>🏗️ Artifactory Dashboard</h1>
|
||||
<div class="user-info">
|
||||
<span id="userInfo">Loading...</span>
|
||||
<button class="logout-btn" onclick="logout()">Logout</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div id="alert" class="alert alert-info">
|
||||
<strong>Welcome!</strong> You have successfully authenticated with Active Directory.
|
||||
</div>
|
||||
|
||||
<div class="cards">
|
||||
<div class="card">
|
||||
<h3>📦 Debian Repository</h3>
|
||||
<p>Manage and distribute Debian packages for arm64 and amd64 architectures.</p>
|
||||
<a href="/debian" class="api-link">Browse Packages</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>⛵ Helm Charts</h3>
|
||||
<p>Store and manage Helm charts for Kubernetes deployments.</p>
|
||||
<a href="/charts" class="api-link">Browse Charts</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>🐳 Docker Registry</h3>
|
||||
<p>Manage Docker images and container registries.</p>
|
||||
<a href="/docker" class="api-link">Browse Images</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>🔧 API Documentation</h3>
|
||||
<p>Explore the REST API endpoints and interactive documentation.</p>
|
||||
<a href="/docs" class="api-link">View API Docs</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>📊 Health Status</h3>
|
||||
<p>Monitor the health and status of all artifactory services.</p>
|
||||
<a href="/health" class="api-link">View Health</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>👥 User Management</h3>
|
||||
<p>Manage users and permissions for the artifactory services.</p>
|
||||
<a href="/users" class="api-link">Manage Users</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function loadUserInfo() {
|
||||
try {
|
||||
const response = await fetch('/auth/user', {
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const user = await response.json();
|
||||
document.getElementById('userInfo').textContent =
|
||||
`${user.display_name || user.username} (${user.email})`;
|
||||
document.getElementById('alert').style.display = 'block';
|
||||
} else {
|
||||
// Redirect to login if not authenticated
|
||||
window.location.href = '/';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load user info:', error);
|
||||
window.location.href = '/';
|
||||
}
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
try {
|
||||
await fetch('/auth/logout', {
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
// Clear local storage
|
||||
localStorage.removeItem('auth_token');
|
||||
localStorage.removeItem('auth_timestamp');
|
||||
|
||||
// Redirect to login
|
||||
window.location.href = '/';
|
||||
} catch (error) {
|
||||
console.error('Logout error:', error);
|
||||
// Still redirect to login
|
||||
window.location.href = '/';
|
||||
}
|
||||
}
|
||||
|
||||
// Load user info on page load
|
||||
document.addEventListener('DOMContentLoaded', loadUserInfo);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
283
arti-api/auth-service/templates/login.html
Normal file
283
arti-api/auth-service/templates/login.html
Normal file
@@ -0,0 +1,283 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Authentication - Artifactory</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
background: white;
|
||||
padding: 2rem;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.login-header {
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.login-header h1 {
|
||||
color: #333;
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.login-header p {
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
input[type="text"],
|
||||
input[type="password"] {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 2px solid #e1e1e1;
|
||||
border-radius: 6px;
|
||||
font-size: 1rem;
|
||||
transition: border-color 0.3s ease;
|
||||
}
|
||||
|
||||
input[type="text"]:focus,
|
||||
input[type="password"]:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.login-button {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.login-button:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.login-button:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding: 12px;
|
||||
margin-bottom: 1rem;
|
||||
border-radius: 6px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.alert-error {
|
||||
background-color: #f8d7da;
|
||||
border: 1px solid #f5c6cb;
|
||||
color: #721c24;
|
||||
}
|
||||
|
||||
.alert-success {
|
||||
background-color: #d4edda;
|
||||
border: 1px solid #c3e6cb;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.loading {
|
||||
display: none;
|
||||
text-align: center;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
border: 3px solid #f3f3f3;
|
||||
border-top: 3px solid #667eea;
|
||||
border-radius: 50%;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.footer {
|
||||
text-align: center;
|
||||
margin-top: 2rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid #e1e1e1;
|
||||
color: #666;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<div class="login-header">
|
||||
<h1>🔐 Sign In</h1>
|
||||
<p>Access Artifactory Services</p>
|
||||
</div>
|
||||
|
||||
<div id="alert" class="alert"></div>
|
||||
|
||||
<form id="loginForm">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" required placeholder="Enter your domain username">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" required placeholder="Enter your password">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="login-button" id="loginButton">
|
||||
Sign In
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="loading" id="loading">
|
||||
<div class="spinner"></div>
|
||||
<p>Authenticating...</p>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<p>Use your Active Directory credentials</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const loginForm = document.getElementById('loginForm');
|
||||
const loginButton = document.getElementById('loginButton');
|
||||
const loading = document.getElementById('loading');
|
||||
const alert = document.getElementById('alert');
|
||||
|
||||
function showAlert(message, type = 'error') {
|
||||
alert.className = `alert alert-${type}`;
|
||||
alert.textContent = message;
|
||||
alert.style.display = 'block';
|
||||
}
|
||||
|
||||
function hideAlert() {
|
||||
alert.style.display = 'none';
|
||||
}
|
||||
|
||||
function setLoading(isLoading) {
|
||||
if (isLoading) {
|
||||
loginButton.disabled = true;
|
||||
loginButton.textContent = 'Signing In...';
|
||||
loading.style.display = 'block';
|
||||
} else {
|
||||
loginButton.disabled = false;
|
||||
loginButton.textContent = 'Sign In';
|
||||
loading.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function storeToken(token) {
|
||||
// Store token in localStorage for client-side access
|
||||
localStorage.setItem('auth_token', token);
|
||||
localStorage.setItem('auth_timestamp', new Date().getTime());
|
||||
}
|
||||
|
||||
function redirectToApp() {
|
||||
// Redirect to the main application or dashboard
|
||||
const returnUrl = new URLSearchParams(window.location.search).get('return_url');
|
||||
window.location.href = returnUrl || '/dashboard';
|
||||
}
|
||||
|
||||
loginForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
hideAlert();
|
||||
setLoading(true);
|
||||
|
||||
const formData = new FormData(loginForm);
|
||||
|
||||
try {
|
||||
const response = await fetch('/auth/login', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
// Store token if provided in header
|
||||
const token = response.headers.get('X-Auth-Token');
|
||||
if (token) {
|
||||
storeToken(token);
|
||||
}
|
||||
|
||||
showAlert(`Welcome back, ${data.user.display_name || data.user.username}!`, 'success');
|
||||
|
||||
// Redirect after a short delay
|
||||
setTimeout(() => {
|
||||
redirectToApp();
|
||||
}, 1500);
|
||||
} else {
|
||||
showAlert(data.message || 'Login failed');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Login error:', error);
|
||||
showAlert('Network error. Please try again.');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
// Check if user is already authenticated
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
try {
|
||||
const response = await fetch('/auth/user', {
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const user = await response.json();
|
||||
showAlert(`Already signed in as ${user.display_name || user.username}`, 'success');
|
||||
setTimeout(() => {
|
||||
redirectToApp();
|
||||
}, 1500);
|
||||
}
|
||||
} catch (error) {
|
||||
// User not authenticated, show login form
|
||||
console.log('User not authenticated');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user