轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像
交易
充值流量¥7起我的订单
文档
工具
提交工单页面收录
heimdall-server

luismachadoreis/heimdall-server

luismachadoreis

A comprehensive authentication and authorization ecosystem for Node.js applications

下载次数: 0状态:社区镜像维护者:luismachadoreis仓库类型:镜像最近更新:1 年前
让 AI 帮你使用轩辕镜像? · 展开查看说明 · 点击收起说明

如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。

只需在 AI 对话中先发送下面这句话即可:

请先完整阅读并严格遵守以下文档中的全部规则与要求:

https://xuanyuan.cloud/agents.md

在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。

查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。

镜像简介
下载命令
镜像标签列表与下载命令
轩辕镜像,不浪费每一次拉取。
点击查看

Heimdall API Server

https://img.shields.io/badge/License-MIT-yellow.svg](https://opensource.org/licenses/MIT) https://img.shields.io/badge/TypeScript-5.8.x-blue?logo=typescript](https://www.typescriptlang.org/) https://img.shields.io/badge/Express-4.18.x-green?logo=express](https://expressjs.com/) https://img.shields.io/badge/Node.js-20.x-green?logo=node.js](https://nodejs.org/) https://img.shields.io/badge/AWS-DynamoDB-orange?logo=amazon-aws](https://aws.amazon.com/dynamodb/) https://img.shields.io/badge/PostgreSQL-17.x-blue?logo=postgresql](https://www.postgresql.org/) https://img.shields.io/badge/Jest-29.x-red?logo=jest](https://jestjs.io/) https://img.shields.io/badge/Serverless-3.x-fd5750?logo=serverless]([***] https://img.shields.io/badge/Docker-28.1.x-2496ED?logo=docker](https://www.docker.com/)

A comprehensive authentication and authorization API server built with Domain-Driven Design (DDD) principles, featuring JWT-based authentication, role-based access control, and flexible database support (AWS DynamoDB or PostgreSQL). Designed for serverless deployment with comprehensive test coverage.

Features

  • 🔐 JWT Authentication: Secure token-based authentication with refresh tokens
  • 👥 Role-Based Access Control: Fine-grained permission management
  • 🏗️ Domain-Driven Design: Clean architecture with separated concerns
  • 📦 TypeScript Support: Full TypeScript implementation with strict typing
  • 🗄️ Flexible Database: Choose between DynamoDB or PostgreSQL
  • ☁️ Serverless Ready: Deploy to AWS Lambda with Serverless Framework
  • 🧪 Comprehensive Testing: 90%+ test coverage with Jest
  • 🛡️ Security First: bcrypt password hashing and JWT security
  • 🚀 Express.js: RESTful API with Express.js framework

Architecture

This project follows Domain-Driven Design (DDD) principles with clean architecture:

src/
├── auth/
│   ├── domain/           # Business logic and entities
│   │   ├── User.ts       # User entity with business rules
│   │   └── UserDomain.ts # Domain services
│   ├── application/      # Use cases and application services
│   │   ├── LoginUseCase.ts
│   │   ├── SignupUseCase.ts
│   │   └── ...
│   ├── infrastructure/   # External concerns (database, etc.)
│   │   ├── UserRepository.ts           # Repository interface
│   │   ├── DynamoDBUserRepository.ts   # DynamoDB implementation
│   │   ├── PostgresUserRepository.ts   # PostgreSQL implementation
│   │   └── UserRepositoryFactory.ts    # Factory for database selection
│   └── api/             # Controllers and routes
│       ├── AuthController.ts
│       ├── AdminController.ts
│       └── AuthRoutes.ts
├── commons/
│   └── infrastructure/   # Shared infrastructure components
│       └── Datasource.ts # Database configuration and connection
├── app.ts              # Express app configuration
├── server.ts           # Development server
└── lambda.ts           # AWS Lambda handler

The architecture follows these key principles:

  • Domain Layer: Contains business logic and rules
  • Application Layer: Orchestrates use cases using domain services
  • Infrastructure Layer: Implements technical concerns like database access
  • API Layer: Handles HTTP requests and responses
  • Repository Pattern: Abstracts database operations with support for both DynamoDB and PostgreSQL
  • Factory Pattern: Dynamically selects the appropriate database implementation

Installation

bash
# Clone the repository
git clone https://github.com/luismr/heimdall.git
cd heimdall/heimdall-server

# Install dependencies
npm install

# Setup environment variables
cp .env.example .env

⚠️ Important Package Dependency: This project requires the @luismr/heimdall-middleware-express package from GitHub Packages. Make sure you:

  1. Have a GitHub personal access token with read:packages scope
  2. Configure npm to use GitHub Packages (via .npmrc)
  3. Set the GITHUB_TOKEN environment variable or provide it during Docker build

Environment Variables

Create a .env file in the project root:

env
# Application Configuration
JWT_SECRET=your-super-secret-jwt-key
USERS_TABLE=HeimdallUsers
PORT=4000
NODE_ENV=development

# Signup Protection (required for creating new users)
SIGNUP_ACCESS_TOKEN=your-signup-access-token
SIGNUP_SECRET_TOKEN=your-signup-secret-token

# Database Selection
DB_TYPE=dynamodb  # Options: 'dynamodb' or 'postgres'

# AWS Credentials (required for DynamoDB)
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
AWS_REGION=us-east-1

# PostgreSQL Configuration (required if DB_TYPE=postgres)
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=heimdall
POSTGRES_PASSWORD=your-secure-password
POSTGRES_DB=heimdall
POSTGRES_SSL=false

⚠️ Important: Always use strong secrets in production environments!

📚 Database Configuration: Set DB_TYPE to either 'dynamodb' or 'postgres' to choose your database backend. Make sure to configure the corresponding environment variables for your chosen database type.

Database Configuration

Database Selection

The system uses the DB_TYPE environment variable to determine which database to use:

  • Set DB_TYPE=dynamodb for AWS DynamoDB
  • Set DB_TYPE=postgres for PostgreSQL

Make sure to configure the corresponding environment variables for your chosen database:

  • For DynamoDB: Configure AWS credentials and USERS_TABLE
  • For PostgreSQL: Configure all POSTGRES_* variables

DynamoDB Setup

If using DynamoDB, ensure your AWS credentials are properly configured and the USERS_TABLE exists in your DynamoDB instance.

bash
# Create DynamoDB table using AWS CLI
aws dynamodb create-table \
  --table-name HeimdallUsers \
  --attribute-definitions AttributeName=username,AttributeType=S \
  --key-schema AttributeName=username,KeyType=HASH \
  --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

PostgreSQL Setup

If using PostgreSQL, follow these steps:

  1. Install PostgreSQL 17.x (recommended) or later
  2. Create a database and user:
sql
CREATE DATABASE heimdall;
CREATE USER heimdall WITH ENCRYPTED PASSWORD 'your-secure-password';
GRANT ALL PRIVILEGES ON DATABASE heimdall TO heimdall;
  1. Run database migrations:
bash
# Run all pending migrations
npm run typeorm:migration:run

# Revert the last applied migration
npm run typeorm:migration:revert

# Create a new empty migration (for development)
npm run typeorm:migration:create -- -n YourMigrationName

# Generate a migration from entity changes (for development)
npm run typeorm:migration:generate -- -n YourMigrationName

The migrations will:

  • Create the users table with all necessary columns
  • Set up indexes for optimal query performance
  • Configure foreign key constraints if needed
  • Handle any future schema changes

The system will automatically detect which database to use based on your environment configuration:

  • If POSTGRES_HOST is set, PostgreSQL will be used
  • Otherwise, DynamoDB will be used

Docker

Building the Docker Image

The project uses GitHub Packages which requires authentication to access the required @luismr/heimdall-middleware-express package. You'll need a GitHub personal access token with read:packages scope.

bash
# Build the Docker image with GitHub token
docker build -t heimdall-server . --build-arg GITHUB_TOKEN=your_github_token

# Build with a specific tag
docker build -t heimdall-server:1.0.0 . --build-arg GITHUB_TOKEN=your_github_token

# If you have the token in an environment variable
docker build -t heimdall-server . --build-arg GITHUB_TOKEN=${GITHUB_TOKEN}

⚠️ Security Note: The GitHub token is only used during build time and is not included in the final image. The .npmrc file is removed after dependency installation.

CI/CD Configuration

For automated Docker builds in GitHub Actions, you need to configure the following secrets:

  • GH_PACKAGES_TOKEN: A GitHub personal access token with read:packages scope for accessing the middleware package
  • DOCKERHUB_USERNAME: Your Docker Hub username
  • DOCKERHUB_TOKEN: Your Docker Hub access token

Running with Docker

bash
# Run the container
docker run -d \
  -p 4000:4000 \
  --name heimdall \
  --env-file .env \
  heimdall-server

# View container logs
docker logs -f heimdall

# Stop the container
docker stop heimdall

# Remove the container
docker rm heimdall

Environment Variables with Docker

When running with Docker, make sure to:

  1. Create your .env file as described in the Environment Variables section
  2. Pass the environment file to Docker using the --env-file flag
  3. If using PostgreSQL, ensure the POSTGRES_HOST is accessible from within the container
  4. If using DynamoDB, ensure AWS credentials are properly configured in the environment file

Docker Compose (Optional)

For development with PostgreSQL, you can use this docker-compose.yml:

yaml
version: '3.8'
services:
  app:
    build: .
    ports:
      - "4000:4000"
    env_file: .env
    depends_on:
      - postgres
    
  postgres:
    image: postgres:17-alpine
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: heimdall
      POSTGRES_PASSWORD: your-secure-password
      POSTGRES_DB: heimdall
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Run with Docker Compose:

bash
# Start all services
docker-compose up -d

# View logs
docker-compose logs -f

# Stop all services
docker-compose down

Quick Start

Development Server

bash
# Start development server with hot reload
npm run dev

# The API will be available at http://localhost:4000

Serverless Local Development

bash
# Start serverless offline
npm run serverless:dev

# The API will be available at http://localhost:4000

Testing

bash
# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

API Endpoints

Base URL

  • Development: http://localhost:4000/api
  • Production: https://your-api-domain.com/api

Authentication Endpoints

POST /signup

Register a new user account. This endpoint requires special authentication tokens to prevent unauthorized user creation.

Headers Required:

http
X-Access-Token: your-signup-access-token
X-Secret-Token: your-signup-secret-token

Request Body:

json
{
  "username": "johndoe",
  "password": "securepassword123"
}

Response:

json
{
  "username": "johndoe",
  "roles": ["ROLE_USER"],
  "blocked": false
}

Error Responses:

  • 401 Unauthorized: Missing or invalid signup tokens
  • 400 Bad Request: Invalid request body or user already exists
  • 500 Internal Server Error: Server configuration error (tokens not configured)

POST /login

Authenticate user and get JWT tokens.

Request:

json
{
  "username": "johndoe",
  "password": "securepassword123"
}

Response:

json
{
  "user": {
    "username": "johndoe",
    "roles": ["ROLE_USER"],
    "blocked": false
  },
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

POST /logout 🔒

Logout user and invalidate refresh token.

Headers:

Authorization: Bearer <access-token>

Request:

json
{
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Response:

json
{
  "message": "Logged out successfully"
}

Admin Endpoints

All admin endpoints require ROLE_ADMIN role.

POST /admin/block 🔒👑

Block a user account.

Headers:

Authorization: Bearer <admin-access-token>

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 heimdall-server 镜像标签

docker pull docker.xuanyuan.run/luismachadoreis/heimdall-server:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull luismachadoreis/heimdall-server:<标签>

轩辕镜像配置手册

按平台快速找到配置文档

一键安装

一键安装 Docker

Linux Docker 一键安装

AI

用 AI 使用轩辕镜像

agents.md · AI 对话 · 提示词

Docker

登录仓库拉取

登录认证 · 私有仓库

专属域名拉取

免登录 · 高速拉取

Linux

Docker 镜像配置

Windows / Mac

Docker Desktop 配置

MacOS OrbStack

OrbStack 容器

Apple Container

macOS 原生容器

Docker Compose

Compose 项目配置

NAS

群晖

Synology 配置

飞牛

fnOS 镜像配置

绿联

绿联 NAS

威联通

QNAP 配置

极空间

极空间 NAS

Unraid

Unraid NAS

企业仓库

其他仓库

ghcr · Quay · nvcr

Harbor 镜像源

Proxy Repository 对接

Portainer 镜像源

Registries 配置

Nexus 镜像源

Docker Proxy 缓存

开发工具

Dev Containers

VS Code 开发容器

Podman

Podman 配置指南

Singularity / Apptainer

HPC 科学计算容器

Kubernetes

K8s Containerd

Kubernetes · Containerd

K3s

轻量级集群

面板 / 网络

爱快路由

iKuai 镜像加速

宝塔面板

一键配置镜像源

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

功能

版本功能对比

功能对比 · 版本选择

支持的镜像仓库

Docker Hub · GCR · GHCR

新手拉取配置

登录 · 专属域名 · 配置

docker search 限制

专属域名 · Hub 搜索

不支持 push

仅支持 pull · 不支持

拉取速度原因

带宽 · 缓存 · 冷热镜像

错误码

402 与流量用尽

402 · 流量包 · 充值

401 认证失败

401 · docker login

manifest unknown

标签错误 · 镜像不存在

410 Gone 排查

410 · Docker 升级

429 限流

免费版 · 专业版 · 企业版 · 请求频率

其他报错

DNS 超时

DNS 解析 · 网络超时

TLS 证书失败

no matching manifest(架构)

账号

失败是否计费

manifest · blob · 计费

申请开发票(企业 / 个人)

企业 · 个人 · 工单

修改登录密码

网站 · 仓库 · 重置

注销账户

工单 · 数据 · 注销

原理

mirrors 不生效

daemon.json · 重启

去掉域名前缀

docker tag · 重命名

指定架构拉取

ARM64 · AMD64 · 多架构

latest 与「最新」

digest · 版本号 · 标签

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
luismachadoreis/heimdall-server
定价查看流量套餐与价格
博客Docker 镜像公告与技术博客
专业版 · 高速稳定拉取镜像
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
50GB 仅 ¥7/年
专业版 · 高速稳定拉取镜像
50GB 仅 ¥7/年
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
用户协议·隐私政策·增值电信业务经营许可证:浙B2-20261007·©2024-2026 源码跳动©2024-2026 杭州源码跳动科技有限公司·商务合作:点击复制邮箱

更多 heimdall-server 镜像推荐

linuxserver/heimdall logo

linuxserver/heimdall

LinuxServer.io 社区镜像
linuxserver/heimdall 是一款轻量高效的Docker应用仪表板镜像,专为集中管理各类Web服务、应用和工具设计。支持自定义布局、分类整理与图标显示,可将常用服务(如NAS管理、智能家居平台、媒体服务器等)整合为直观入口,实现一键快速访问。采用响应式界面,适配电脑、平板及手机设备,操作简单且资源占用低,是个人服务器、家庭实验室或多服务环境下优化访问体验的理想工具。
1.2千 次收藏5亿+ 次下载
4 天前更新
linuxserver/code-server logo

linuxserver/code-server

LinuxServer.io 社区镜像
linuxserver/code-server是VS Code服务器版Docker镜像,可在浏览器中运行完整VS Code开发环境,无需本地安装即可跨设备访问。支持全部VS Code扩展、代码同步与终端功能,适配远程开发、团队协作或低配置设备场景。镜像经linuxserver优化,兼容ARM/AMD架构,内置持久化存储与安全配置,开箱即用,轻松打造云端IDE,提升开发灵活性与效率。
739 次收藏5000万+ 次下载
4 天前更新
linuxserver/openssh-server logo

linuxserver/openssh-server

LinuxServer.io 社区镜像
提供OpenSSH服务器服务,支持远程登录与服务器管理,具备易于部署、配置灵活的特点,适用于各类需要安全远程访问的场景。
146 次收藏1000万+ 次下载
9 天前更新
mailserver/docker-mailserver logo

mailserver/docker-mailserver

mailserver
一个全栈且简单易用的邮件服务器,支持SMTP、IMAP协议,集成LDAP、反垃圾邮件及反病毒等功能。
265 次收藏1000万+ 次下载
4 天前更新
mitre/heimdall logo

mitre/heimdall

mitre
Heimdall是InSpec评估和配置文件的集中可视化服务器,现该仓库已被heimdall2取代,请更新相关链接。
2 次收藏50万+ 次下载
5 年前更新
linuxserver/sonarr logo

linuxserver/sonarr

LinuxServer.io 社区镜像
由LinuxServer.io提供的Sonarr容器,是一款专为电视节目集管理设计的自动化工具,能够监控指定剧集的更新信息、自动从索引器获取下载链接并通过下载客户端(如Deluge、qBittorrent等)完成资源下载,同时支持按自定义规则整理文件结构、重命名剧集文件以保持媒体库整洁有序;LinuxServer.io作为专注于提供高质量容器化应用的团队,其构建的Sonarr容器基于轻量级Linux系统,优化了资源占用与运行稳定性,适合家庭媒体服务器或个人影视库的自动化管理场景使用。
2.1千 次收藏10亿+ 次下载
3 天前更新

查看更多 heimdall-server 相关镜像