1121 lines
33 KiB
HTML
1121 lines
33 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="fa" dir="rtl">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>تحلیل فنی معماری سیستم هویت و مدیریت API Keys | xIds</title>
|
||
<style>
|
||
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
|
||
|
||
:root {
|
||
--primary: #1a365d;
|
||
--primary-light: #2c5282;
|
||
--accent: #c9a961;
|
||
--accent-dark: #a8893f;
|
||
--bg: #faf9f6;
|
||
--card-bg: #ffffff;
|
||
--text: #1a202c;
|
||
--text-muted: #4a5568;
|
||
--border: #e2e8f0;
|
||
--success: #38a169;
|
||
--danger: #e53e3e;
|
||
--warning: #dd6b20;
|
||
--info: #3182ce;
|
||
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
|
||
}
|
||
|
||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||
|
||
body {
|
||
font-family: 'Vazirmatn', Tahoma, sans-serif;
|
||
background: var(--bg);
|
||
color: var(--text);
|
||
line-height: 1.9;
|
||
font-size: 15px;
|
||
padding: 30px 15px;
|
||
}
|
||
|
||
.document-container {
|
||
max-width: 950px;
|
||
margin: 0 auto;
|
||
background: var(--card-bg);
|
||
box-shadow: var(--shadow);
|
||
border-radius: 12px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.document-header {
|
||
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
|
||
color: white;
|
||
padding: 50px 40px 40px;
|
||
position: relative;
|
||
border-bottom: 4px solid var(--accent);
|
||
}
|
||
|
||
.document-header::before {
|
||
content: '';
|
||
position: absolute;
|
||
top: 0; right: 0;
|
||
width: 200px; height: 200px;
|
||
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
|
||
border-radius: 50%;
|
||
transform: translate(50%, -50%);
|
||
}
|
||
|
||
.header-top {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 30px;
|
||
position: relative;
|
||
z-index: 1;
|
||
}
|
||
|
||
.company-badge {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
}
|
||
|
||
.company-logo {
|
||
width: 60px; height: 60px;
|
||
background: var(--accent);
|
||
border-radius: 12px;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
|
||
}
|
||
|
||
.doc-meta {
|
||
text-align: left;
|
||
font-size: 12px;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.doc-meta div { margin-bottom: 3px; }
|
||
|
||
.document-title {
|
||
text-align: center;
|
||
position: relative;
|
||
z-index: 1;
|
||
padding: 20px 0;
|
||
}
|
||
|
||
.document-title .label {
|
||
display: inline-block;
|
||
background: rgba(201,169,97,0.2);
|
||
color: var(--accent);
|
||
padding: 4px 16px;
|
||
border-radius: 20px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
margin-bottom: 15px;
|
||
border: 1px solid rgba(201,169,97,0.4);
|
||
}
|
||
|
||
.document-title h1 {
|
||
font-size: 28px;
|
||
font-weight: 800;
|
||
margin-bottom: 10px;
|
||
letter-spacing: -0.5px;
|
||
}
|
||
|
||
.document-title h2 {
|
||
font-size: 16px;
|
||
font-weight: 400;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.document-body {
|
||
padding: 40px;
|
||
}
|
||
|
||
.intro-text {
|
||
background: linear-gradient(to left, #f7fafc, #edf2f7);
|
||
border-right: 4px solid var(--accent);
|
||
padding: 20px 25px;
|
||
border-radius: 8px;
|
||
margin-bottom: 35px;
|
||
font-size: 14px;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.section {
|
||
margin-bottom: 40px;
|
||
page-break-inside: avoid;
|
||
}
|
||
|
||
.section-header {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 15px;
|
||
padding-bottom: 12px;
|
||
border-bottom: 2px solid var(--border);
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.section-number {
|
||
width: 50px; height: 50px;
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
border-radius: 12px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-weight: 800;
|
||
font-size: 20px;
|
||
flex-shrink: 0;
|
||
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
|
||
}
|
||
|
||
.section-title { flex: 1; }
|
||
|
||
.section-title h3 {
|
||
font-size: 19px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 2px;
|
||
}
|
||
|
||
.section-title .subtitle {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.section-content {
|
||
padding-right: 10px;
|
||
}
|
||
|
||
.section-content p {
|
||
margin-bottom: 12px;
|
||
text-align: justify;
|
||
text-indent: 20px;
|
||
}
|
||
|
||
.section-content p.no-indent { text-indent: 0; }
|
||
|
||
.highlight-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #f6e05e;
|
||
border-right: 4px solid var(--accent);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.highlight-box strong {
|
||
color: var(--accent-dark);
|
||
}
|
||
|
||
.info-box {
|
||
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
|
||
border: 1px solid #90cdf4;
|
||
border-right: 4px solid var(--primary-light);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.success-box {
|
||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||
border: 1px solid #9ae6b4;
|
||
border-right: 4px solid var(--success);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.warning-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #fbd38d;
|
||
border-right: 4px solid var(--warning);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.styled-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin: 20px 0;
|
||
background: white;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||
}
|
||
|
||
.styled-table thead {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
}
|
||
|
||
.styled-table th {
|
||
padding: 14px 16px;
|
||
text-align: right;
|
||
font-weight: 600;
|
||
font-size: 13px;
|
||
}
|
||
|
||
.styled-table td {
|
||
padding: 13px 16px;
|
||
border-bottom: 1px solid var(--border);
|
||
font-size: 13px;
|
||
}
|
||
|
||
.styled-table tbody tr:last-child td { border-bottom: none; }
|
||
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
|
||
|
||
.styled-table .highlight-row {
|
||
background: #fffaf0 !important;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.comparison-grid {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
gap: 20px;
|
||
margin: 25px 0;
|
||
}
|
||
|
||
.comparison-card {
|
||
background: #f8fafc;
|
||
border: 2px solid var(--border);
|
||
border-radius: 10px;
|
||
padding: 20px;
|
||
position: relative;
|
||
}
|
||
|
||
.comparison-card.recommended {
|
||
border-color: var(--success);
|
||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||
}
|
||
|
||
.comparison-card .card-badge {
|
||
position: absolute;
|
||
top: -10px;
|
||
right: 20px;
|
||
background: var(--success);
|
||
color: white;
|
||
padding: 3px 12px;
|
||
border-radius: 15px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.comparison-card h4 {
|
||
font-size: 16px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 15px;
|
||
padding-bottom: 10px;
|
||
border-bottom: 2px solid var(--border);
|
||
}
|
||
|
||
.comparison-card.recommended h4 {
|
||
border-bottom-color: var(--success);
|
||
}
|
||
|
||
.comparison-card ul {
|
||
list-style: none;
|
||
padding: 0;
|
||
}
|
||
|
||
.comparison-card ul li {
|
||
padding: 8px 0;
|
||
border-bottom: 1px solid var(--border);
|
||
font-size: 13px;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.comparison-card ul li:last-child { border-bottom: none; }
|
||
|
||
.comparison-card ul li .value {
|
||
font-weight: 600;
|
||
color: var(--primary);
|
||
}
|
||
|
||
.quote-box {
|
||
background: linear-gradient(135deg, #f7fafc, #edf2f7);
|
||
border-right: 4px solid var(--accent);
|
||
padding: 20px 25px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
position: relative;
|
||
}
|
||
|
||
.quote-box::before {
|
||
content: '"';
|
||
position: absolute;
|
||
top: -10px;
|
||
right: 15px;
|
||
font-size: 60px;
|
||
color: var(--accent);
|
||
opacity: 0.3;
|
||
font-family: Georgia, serif;
|
||
}
|
||
|
||
.quote-box p {
|
||
font-style: italic;
|
||
color: var(--text-muted);
|
||
margin-bottom: 10px;
|
||
text-indent: 0 !important;
|
||
}
|
||
|
||
.quote-box .source {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
text-align: left;
|
||
font-style: normal;
|
||
}
|
||
|
||
.stats-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(3, 1fr);
|
||
gap: 15px;
|
||
margin: 25px 0;
|
||
}
|
||
|
||
.stat-card {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
padding: 20px;
|
||
border-radius: 10px;
|
||
text-align: center;
|
||
box-shadow: 0 4px 12px rgba(26,54,93,0.2);
|
||
}
|
||
|
||
.stat-card .stat-value {
|
||
font-size: 24px;
|
||
font-weight: 800;
|
||
margin-bottom: 5px;
|
||
color: var(--accent);
|
||
line-height: 1.3;
|
||
}
|
||
|
||
.stat-card .stat-label {
|
||
font-size: 12px;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.architecture-diagram {
|
||
background: #f8fafc;
|
||
border: 1px solid var(--border);
|
||
border-radius: 8px;
|
||
padding: 25px;
|
||
margin: 25px 0;
|
||
}
|
||
|
||
.architecture-diagram h4 {
|
||
font-size: 16px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 20px;
|
||
text-align: center;
|
||
}
|
||
|
||
.layer {
|
||
margin: 10px 0;
|
||
padding: 15px;
|
||
background: white;
|
||
border-radius: 6px;
|
||
border-right: 4px solid var(--accent);
|
||
}
|
||
|
||
.layer h5 {
|
||
font-size: 14px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
.layer ul {
|
||
list-style: none;
|
||
padding: 0;
|
||
margin: 0;
|
||
}
|
||
|
||
.layer ul li {
|
||
padding: 5px 0;
|
||
padding-right: 20px;
|
||
position: relative;
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.layer ul li::before {
|
||
content: '▸';
|
||
position: absolute;
|
||
right: 0;
|
||
color: var(--accent);
|
||
}
|
||
|
||
.security-badge {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
background: linear-gradient(135deg, #1a202c, #2d3748);
|
||
color: white;
|
||
padding: 10px 18px;
|
||
border-radius: 20px;
|
||
font-size: 13px;
|
||
margin: 10px 0;
|
||
}
|
||
|
||
.security-badge span {
|
||
font-size: 18px;
|
||
}
|
||
|
||
.tag {
|
||
display: inline-block;
|
||
padding: 4px 10px;
|
||
border-radius: 12px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
margin: 3px;
|
||
}
|
||
|
||
.tag.primary {
|
||
background: var(--primary);
|
||
color: white;
|
||
}
|
||
|
||
.tag.success {
|
||
background: var(--success);
|
||
color: white;
|
||
}
|
||
|
||
.tag.warning {
|
||
background: var(--warning);
|
||
color: white;
|
||
}
|
||
|
||
.tag.info {
|
||
background: var(--info);
|
||
color: white;
|
||
}
|
||
|
||
.flow-steps {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||
gap: 15px;
|
||
margin: 25px 0;
|
||
}
|
||
|
||
.flow-step {
|
||
background: linear-gradient(135deg, #f7fafc, #edf2f7);
|
||
border: 2px solid var(--border);
|
||
border-radius: 10px;
|
||
padding: 20px;
|
||
text-align: center;
|
||
position: relative;
|
||
transition: all 0.3s ease;
|
||
}
|
||
|
||
.flow-step:hover {
|
||
transform: translateY(-3px);
|
||
box-shadow: 0 8px 20px rgba(0,0,0,0.1);
|
||
border-color: var(--accent);
|
||
}
|
||
|
||
.flow-step-number {
|
||
width: 40px; height: 40px;
|
||
background: var(--accent);
|
||
color: white;
|
||
border-radius: 50%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-weight: 800;
|
||
font-size: 18px;
|
||
margin: 0 auto 12px;
|
||
}
|
||
|
||
.flow-step h5 {
|
||
font-size: 14px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
.flow-step p {
|
||
font-size: 11px;
|
||
color: var(--text-muted);
|
||
margin: 0;
|
||
text-indent: 0 !important;
|
||
}
|
||
|
||
.arrow {
|
||
text-align: center;
|
||
font-size: 20px;
|
||
color: var(--accent);
|
||
margin: 5px 0;
|
||
}
|
||
|
||
.conclusion-box {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
padding: 30px;
|
||
border-radius: 12px;
|
||
margin: 30px 0;
|
||
text-align: center;
|
||
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
|
||
}
|
||
|
||
.conclusion-box h3 {
|
||
font-size: 22px;
|
||
font-weight: 800;
|
||
margin-bottom: 15px;
|
||
color: var(--accent);
|
||
}
|
||
|
||
.conclusion-box p {
|
||
font-size: 14px;
|
||
line-height: 1.8;
|
||
text-indent: 0 !important;
|
||
margin-bottom: 15px;
|
||
}
|
||
|
||
.conclusion-box .highlight {
|
||
background: rgba(201,169,97,0.2);
|
||
padding: 15px 20px;
|
||
border-radius: 8px;
|
||
margin-top: 20px;
|
||
border: 1px solid rgba(201,169,97,0.4);
|
||
}
|
||
|
||
.document-footer {
|
||
background: var(--primary);
|
||
color: white;
|
||
padding: 25px 40px;
|
||
text-align: center;
|
||
font-size: 12px;
|
||
margin-top: 40px;
|
||
}
|
||
|
||
.document-footer .footer-brand {
|
||
font-weight: 700;
|
||
color: var(--accent);
|
||
margin-bottom: 5px;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.footer-divider {
|
||
width: 60px;
|
||
height: 2px;
|
||
background: var(--accent);
|
||
margin: 10px auto;
|
||
}
|
||
|
||
.page-info {
|
||
text-align: center;
|
||
padding: 15px;
|
||
font-size: 11px;
|
||
color: var(--text-muted);
|
||
border-top: 1px solid var(--border);
|
||
margin-top: 30px;
|
||
}
|
||
|
||
@media print {
|
||
body { background: white; padding: 0; }
|
||
.document-container { box-shadow: none; border-radius: 0; }
|
||
.section { page-break-inside: avoid; }
|
||
}
|
||
|
||
@media (max-width: 768px) {
|
||
.document-body { padding: 25px 20px; }
|
||
.document-header { padding: 30px 20px; }
|
||
.comparison-grid { grid-template-columns: 1fr; }
|
||
.stats-grid { grid-template-columns: 1fr; }
|
||
.header-top { flex-direction: column; gap: 15px; }
|
||
.doc-meta { text-align: center; }
|
||
.flow-steps { grid-template-columns: 1fr; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<div class="document-container">
|
||
|
||
<header class="document-header">
|
||
<div class="header-top">
|
||
<div class="company-badge">
|
||
<div class="company-logo"></div>
|
||
</div>
|
||
<div class="doc-meta">
|
||
<div>شماره مستند: TECH-1405-003</div>
|
||
<div>نسخه: ۱.۰</div>
|
||
<div>تاریخ تهیه: شهریور ۱۴۰۵</div>
|
||
<div>طبقهبندی: داخلی</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="document-title">
|
||
<span class="label">TECHNICAL ANALYSIS</span>
|
||
<h1>تحلیل فنی معماری سیستم هویت و مدیریت API Keys</h1>
|
||
<h2>معماری xIds IdentityServer & Application Management</h2>
|
||
</div>
|
||
</header>
|
||
|
||
<div class="document-body">
|
||
|
||
<div class="intro-text">
|
||
<strong>محترماً،</strong><br>
|
||
این مستند تحلیل جامع و فنی از کد منبع سیستم xIds را ارائه میدهد. هدف از تهیه این مستند، تبیین ساختار معماری، الگوهای طراحی، و استراتژیهای امنیتی پیادهسازیشده میباشد.
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۱</div>
|
||
<div class="section-title">
|
||
<h3>خلاصه اجرایی</h3>
|
||
<div class="subtitle">Executive Summary</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>سیستم xIds یک راهحل جامع هویت و مدیریت دسترسی بر پایه IdentityServer4 است که شامل مدیریت کاربران، API Keys، و سیستمهای همکاری اجتماعی میباشد. این سیستم از معماری مدرن ASP.NET Core 5+ استفاده کرده و بر اصول Clean Architecture و Dependency Injection استوار است.</p>
|
||
|
||
<div class="stats-grid">
|
||
<div class="stat-card">
|
||
<div class="stat-value">IdentityServer4</div>
|
||
<div class="stat-label">برونافزایی استاندارد OAuth2/OIDC</div>
|
||
</div>
|
||
<div class="stat-card">
|
||
<div class="stat-value">Soft Delete</div>
|
||
<div class="stat-label">حذف نرم برای بازیابی دادهها</div>
|
||
</div>
|
||
<div class="stat-card">
|
||
<div class="stat-value">Rate Limiting</div>
|
||
<div class="stat-label">محدودیت درخواست برای امنیت API</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="highlight-box">
|
||
<strong>نتیجه کلیدی:</strong> سیستم از معماری چندلایه با تفکیک واضح مسئولیتها استفاده کرده و بر امنیت، مقیاسپذیری و قابلیت نگهداری تمرکز دارد.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۲</div>
|
||
<div class="section-title">
|
||
<h3>معماری کلی سیستم</h3>
|
||
<div class="subtitle">System Architecture</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<div class="architecture-diagram">
|
||
<h4>🏗️ معماری چندلایه سیستم xIds</h4>
|
||
|
||
<div class="layer">
|
||
<h5>۱. Presentation Layer (Controllers & API Endpoints)</h5>
|
||
<ul>
|
||
<li>AccountController: مدیریت احراز هویت، ثبتنام و پروفایل</li>
|
||
<li>ApplicationsController: مدیریت API Keys و Applications</li>
|
||
<li>Base Controllers: XIBaseController برای منطق مشترک</li>
|
||
<li>DTOs: دادههای انتقالی بین لایهها</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="layer">
|
||
<h5>۲. Business Logic Layer (Interfaces & Providers)</h5>
|
||
<ul>
|
||
<li>IXIdentityManager: مدیریت مرکزی هویت و کاربران</li>
|
||
<li>IXApplicationProvider: مدیریت Applications و API Keys</li>
|
||
<li>IXIdentityHelper: توابع کمکی امنیتی و توکنسازی</li>
|
||
<li>IXSecurityProvider: رمزنگاری و رمزگشایی دادهها</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="layer">
|
||
<h5>۳. Data Access Layer (DbContext & Migrations)</h5>
|
||
<ul>
|
||
<li>XIdentityDbContext: Entity Framework Core برای دادههای هویت</li>
|
||
<li>PersistedGrantDbContext: ذخیرهسازی گرانتهای IdentityServer</li>
|
||
<li>ConfigurationDbContext: تنظیمات و منابع IdentityServer</li>
|
||
<li>Soft Delete Pattern: پشتیبانی از حذفهای برگشتپذیر</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="layer">
|
||
<h5>۴. Infrastructure Layer (IdentityServer & External Services)</h5>
|
||
<ul>
|
||
<li>IdentityServer4 Core: پروتکلهای استاندارد OAuth2/OIDC</li>
|
||
<li>Message Provider: ارسال پیامهای ایمیل و SMS</li>
|
||
<li>Storage Provider: مدیریت فایلهای پروفایل</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۳</div>
|
||
<div class="section-title">
|
||
<h3>مدیریت هویت و احراز هویت</h3>
|
||
<div class="subtitle">Identity & Authentication Management</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>سیستم از IdentityServer4 به عنوان هسته مرکزی احراز هویت استفاده میکند و چندین سناریوی احراز هویت پیادهسازی کرده است:</p>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>سناریو</th>
|
||
<th>مکانیسم</th>
|
||
<th>کاربرد</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>احراز هویت رمز عبور</td>
|
||
<td>XResourceOwnerPasswordValidator</td>
|
||
<td>برای ورود کاربران عادی</td>
|
||
</tr>
|
||
<tr>
|
||
<td>API Key Authentication</td>
|
||
<td>XApiKeyAuthenticationHandler</td>
|
||
<td>برای سرویسهای خارجی و اتوماسیون</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Refresh Tokens</td>
|
||
<td>Extendable Token Lifetime</td>
|
||
<td>دوام امنتر توکنها بدون رفرش مکرر</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="security-badge">
|
||
<span>🔐</span>
|
||
<div>
|
||
<strong>امنیت توکنها:</strong><br>
|
||
رمزنگاری HMAC-SHA256 + Soft Validation + Automatic Expiry Handling
|
||
</div>
|
||
</div>
|
||
|
||
<div class="info-box">
|
||
<strong>🔄 احراز هویت دو مرحلهای:</strong><br>
|
||
سیستم از مکانیسم Device + Token برای ایجاد توکنهای امنتر استفاده میکند. هر دستگاه دارای شناسه یکتا و توکن اختصاصی است.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۴</div>
|
||
<div class="section-title">
|
||
<h3>مدیریت API Keys و Applications</h3>
|
||
<div class="subtitle">API Key & Application Management</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>سیستم یک سیستم مدیریت پیشرفته API Keys ارائه میدهد که شامل ویژگیهای امنیتی و عملیاتی متعدد است:</p>
|
||
|
||
<div class="comparison-grid">
|
||
<div class="comparison-card">
|
||
<h4>ویژگیهای کلیدی</h4>
|
||
<ul>
|
||
<li><span>Hashing</span> <span class="value">SHA-256 برای Key Hash</span></li>
|
||
<li><span>Scopes</span> <span class="value">محدودیت دسترسی بر اساس Scope</span></li>
|
||
<li><span>Rate Limit</span> <span class="value">محدودیت نرخ درخواست</span></li>
|
||
<li><span>IP Whitelist</span> <span class="value">لیست سفید IPها</span></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="comparison-card recommended">
|
||
<span class="card-badge">پیشنهاد ما ✓</span>
|
||
<h4>الگوهای امنیتی</h4>
|
||
<ul>
|
||
<li><span>Soft Delete</span> <span class="value">حذف نرم برای بازیابی</span></li>
|
||
<li><span>Expiry</span> <span class="value">تاریخ انقضا خودکار</span></li>
|
||
<li><span>Revocation</span> <span class="value">انهدام فوری</span></li>
|
||
<li><span>Audit Log</span> <span class="value">ضبط تمام فعالیتها</span></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>عملیات</th>
|
||
<th>مکانیسم</th>
|
||
<th>نکات امنیتی</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>ایجاد API Key</td>
|
||
<td>Random 32-byte + Base64 + Hash</td>
|
||
<td>Prefix اختصاصی + Application Link</td>
|
||
</tr>
|
||
<tr>
|
||
<td>اعتبارسنجی</td>
|
||
<td>Hash Match + IP Check + Rate Limit</td>
|
||
<td>Scope Validation + Usage Logging</td>
|
||
</tr>
|
||
<tr>
|
||
<td>بازیابی</td>
|
||
<td>Soft Delete + Audit Trail</td>
|
||
<td>Owner Verification Required</td>
|
||
</tr>
|
||
</tbody>
|
||
</div>
|
||
|
||
<div class="highlight-box">
|
||
<strong>📊 محدودیتها و سیاستها:</strong><br>
|
||
- حداکثر 10 API Key به ازای هر Application<br>
|
||
- محدودیت انقضا: 30 روز تا 1 سال<br>
|
||
- Rate Limit: قابل تنظیم به صورت پویا
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۵</div>
|
||
<div class="section-title">
|
||
<h3>الگوهای طراحی و معماری</h3>
|
||
<div class="subtitle">Design Patterns & Architectural Decisions</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>الگو</th>
|
||
<th>کاربرد در سیستم</th>
|
||
<th>مزیت</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>Repository Pattern</td>
|
||
<td>IXApplicationProvider, IXIdentityManager</td>
|
||
<td>تفکیک منطق کسبوکار از دسترسی به داده</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Dependency Injection</td>
|
||
<td>Startup.ConfigureServices</td>
|
||
<td>قابل تست و قابل نگهداری</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Soft Delete</td>
|
||
<td>Deleted Flag in Entities</td>
|
||
<td>حفظ تاریخچه + بازیابی داده</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Strategy Pattern</td>
|
||
<td>IXIdentityHelper, IXSecurityProvider</td>
|
||
<td>تعویض آسان الگوریتمهای امنیتی</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="quote-box">
|
||
<p>استفاده از Soft Delete به جای حذف فوری، امکان بازگرداندن دادهها، تحلیل رفتار کاربران، و حفظ تاریخچه فعالیتها را فراهم میکند - یک تصمیم طراحی عالی برای سیستمهای حساس به داده.</p>
|
||
<div class="source">— Architectural Decision Record</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۶</div>
|
||
<div class="section-title">
|
||
<h3>روندهای امنیتی کلیدی</h3>
|
||
<div class="subtitle">Key Security Implementations</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<div class="security-badge">
|
||
<span>🛡️</span>
|
||
<div>
|
||
<strong>اعتبارسنجی دو لایه:</strong><br>
|
||
Hash Validation + Expiry Check + Scope Authorization
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flow-steps">
|
||
<div class="flow-step">
|
||
<div class="flow-step-number">۱</div>
|
||
<h5>دریافت درخواست</h5>
|
||
<p>API Key از Header دریافت میشود و Client IP ثبت میگردد</p>
|
||
</div>
|
||
<div class="arrow">↓</div>
|
||
<div class="flow-step">
|
||
<div class="flow-step-number">۲</div>
|
||
<h5>اعتبارسنجی Hash</h5>
|
||
<p>SHA-256 Hash محاسبه و با مقدار ذخیرهشده مقایسه میشود</p>
|
||
</div>
|
||
<div class="arrow">↓</div>
|
||
<div class="flow-step">
|
||
<div class="flow-step-number">۳</div>
|
||
<h5>بررسی Scope</h5>
|
||
<p>محدودیت دسترسیها بر اساس درخواست بررسی میشود</p>
|
||
</div>
|
||
<div class="arrow">↓</div>
|
||
<div class="flow-step">
|
||
<div class="flow-step-number">۴</div>
|
||
<h5>ضبط لاگ</h5>
|
||
<p>تمامی فعالیتها در جدول ApiKeyUsages ثبت میشوند</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>لایه امنیتی</th>
|
||
<th>مکانیسم</th>
|
||
<th>مخاطره کاهشیافته</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>معماری</td>
|
||
<td>Soft Delete + Audit Trail</td>
|
||
<td>از دست دادن دادهها و عدم شفافیت</td>
|
||
</tr>
|
||
<tr>
|
||
<td>اعتبارسنجی</td>
|
||
<td>Hash + Rate Limit + IP Check</td>
|
||
<td>برخوردن به API غیرمجاز</td>
|
||
</tr>
|
||
<tr>
|
||
<td>مدیریت توکن</td>
|
||
<td>Extendable Lifetime + Revocation</td>
|
||
<td>دوام بیشازحد توکنها</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۷</div>
|
||
<div class="section-title">
|
||
<h3>پایگاه داده و مigrations</h3>
|
||
<div class="subtitle">Database Architecture & Migrations</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>سیستم از Entity Framework Core با پشتیبانی کامل از Migrations استفاده میکند:</p>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>پایگاه داده</th>
|
||
<th>جدولهای کلیدی</th>
|
||
<th>هدف</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>XIdentityDb</td>
|
||
<td>ApiKeys, Applications, Users, Devices</td>
|
||
<td>دادههای هویت و کاربر</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ConfigurationDb</td>
|
||
<td>IdentityResources, ApiResources, Clients</td>
|
||
<td>تنظیمات IdentityServer</td>
|
||
</tr>
|
||
<tr>
|
||
<td>PersistedGrantDb</td>
|
||
<td>DeviceCodes, PersistedGrants</td>
|
||
<td>مدیریت توکنهای فعال</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="info-box">
|
||
<strong>💾 استراتژی نگهداری داده:</strong><br>
|
||
- Indexes: برای سطوح کلیدی مانند KeyHash و ExpiresAt<br>
|
||
- Foreign Keys: برای یکپارچگی دادهها<br>
|
||
- Seed Data: برای راهاندازی اولیه سیستم
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۸</div>
|
||
<div class="section-title">
|
||
<h3>جمعبندی و ارزیابی نهایی</h3>
|
||
<div class="subtitle">Final Assessment & Conclusion</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>با توجه به تحلیل جامع انجامشده، سیستم xIds یک معماری مدرن و امن برای مدیریت هویت و API Keys ارائه میدهد. نقاط قوت و بهبودهای پیشنهادی به شرح زیر است:</p>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>سطح ارزیابی</th>
|
||
<th>جزئیات</th>
|
||
<th>اولویت</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>کیفیت کد</td>
|
||
<td>عالی - کد تمیز، کامنتگذاریشده، پیادهسازی الگوها</td>
|
||
<td>✓</td>
|
||
</tr>
|
||
<tr>
|
||
<td>امنیت</td>
|
||
<td>بسیار خوب - چندلایه، توکنسازی پیشرفته، Hashing</td>
|
||
<td>✓</td>
|
||
</tr>
|
||
<tr>
|
||
<td>مقیاسپذیری</td>
|
||
<td>خوب - DI، Repository Pattern، Async/await</td>
|
||
<td>✓</td>
|
||
</tr>
|
||
<tr>
|
||
<td>قابلیت نگهداری</td>
|
||
<td>عالی - Migrations، Soft Delete، Audit Logs</td>
|
||
<td>✓</td>
|
||
</tr>
|
||
<tr>
|
||
<td>مستندات</td>
|
||
<td>خوب - کامنتهای داخلی، نیاز به مستندات API</td>
|
||
<td>📋</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="conclusion-box">
|
||
<h3>🎯 نتیجهگیری نهایی</h3>
|
||
<p>سیستم xIds از نظر فنی یک راهحل حرفهای و صنعتی برای مدیریت هویت و دسترسی است. معماری چندلایه، استفاده از IdentityServer4 استاندارد، و پیادهسازی الگوهای طراحی مدرن، نشاندهنده درک عمیق از نیازهای سیستمهای Enterprise است.</p>
|
||
<p>نقطه قوت برجسته این سیستم، تمرکز بر امنیت دادهها، قابلیت نگهداری بلندمدت، و انعطافپذیری در گسترش قابلیتهاست.</p>
|
||
<div class="highlight">
|
||
<strong>💎 ارزیابی کلی: 9.0/10</strong><br>
|
||
سیستم برای استفاده در محیطهای production کاملاً آماده است.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="page-info">
|
||
این مستند فنی صرفاً جهت تحلیل معماری سیستم xIds تهیه شده است. تمامی حقوق کد و معماری محفوظ میباشد.
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<footer class="document-footer">
|
||
<div class="footer-brand">تحلیل فنی: هادی خزاعی اصل</div>
|
||
<div class="footer-divider"></div>
|
||
<div>تاریخ تهیه: شهریور ۱۴۰۵ | نسخه: ۱.۰ | طبقهبندی: داخلی</div>
|
||
</footer>
|
||
|
||
</div>
|
||
|
||
</body>
|
||
</html>
|