# Authentication Dotnet

> Thiết lập Jarvis Authentication — JWT Bearer, API Key, HTTP Basic, AWS Cognito qua AddJarvisAuthentication + Composite scheme. Dùng khi API ASP.NET Core cần xác thực Bearer, header API key, Basic hoặc Cognito qua Jarvis.Authentications.*.

- **Type:** Skill
- **Install:** `agentstack add skill-hoangnh2412-ai-skills-authentication-dotnet`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [hoangnh2412](https://agentstack.voostack.com/s/hoangnh2412)
- **Installs:** 0
- **Category:** [Cloud & Infrastructure](https://agentstack.voostack.com/c/cloud-infrastructure)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [hoangnh2412](https://github.com/hoangnh2412)
- **Source:** https://github.com/hoangnh2412/ai-skills/tree/main/jarvis/skills/authentication-dotnet

## Install

```sh
agentstack add skill-hoangnh2412-ai-skills-authentication-dotnet
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Jarvis.Authentication — Orchestrator

Skill điều phối `Jarvis.Authentications.*` trên ASP.NET Core Host.

**Lưu ý PackageId:** folder repo `Jarvis.Authentication.*` → NuGet **`Jarvis.Authentications.*`** (có **s**). Namespace vẫn là `Jarvis.Authentication.*` (không s).

Hướng dẫn: [README.md](README.md).

## Khi nào dùng workflow nào

| Tình huống | Workflow |
|---|---|
| Host chưa có authentication Jarvis | [workflows/init.md](workflows/init.md) |
| Thêm scheme (JWT / API Key / Basic / Cognito) | [workflows/add.md](workflows/add.md) |

## Quy tắc cốt lõi

- Entry point **bắt buộc**: `builder.Services.AddJarvisAuthentication(configuration, auth => { ... })` — bind section `Authentication`, validate `Type`, đăng ký `IPasswordPolicyValidator`, set Default Authenticate/Challenge scheme. **Không** gọi `services.AddAuthentication()` trực tiếp.
- Satellite `AddCore*` đăng ký **trong callback**: `auth.AddCoreJwtBearer(...)` / `AddCoreApiKey<>` / `AddCoreBasic<>`.
- ≥ 2 scheme → `auth.AddJarvisCompositeScheme(includeBasic: ...)` + `DefaultAuthenticateScheme = "Composite"` (forward theo header: API key → Basic → Bearer).
- Pipeline: `UseAuthentication()` → `UseAuthorization()` **trước** `MapControllers`.
- Nguồn credential là extension point: mặc định `ConfigApiKeyProvider` / `ConfigBasicCredentialProvider` (đọc config), override sang DB/Redis/vault. Provider đăng ký **Singleton** — tra DB dùng `IDbContextFactory`.
- Dùng hằng `JarvisAuthenticationSchemes` (`Composite` / `ApiKey`=`"Default"` / `Basic` / `Bearer`) thay vì hard-code string.
- Swagger security: [swashbuckle-dotnet](../swashbuckle-dotnet/README.md) — `SecuritySchemes` JWT / API_KEY.
- Không commit secret/key/password — env / secret store.

## Packages

| PackageId | Khi nào |
|---|---|
| `Jarvis.Authentications` | Base (entry point, Composite, password policy, hằng scheme) |
| `Jarvis.Authentications.Jwt` | Bearer JWT |
| `Jarvis.Authentications.ApiKey` | Header API key |
| `Jarvis.Authentications.Basic` | HTTP Basic |
| `Jarvis.Authentications.Cognito` | AWS Cognito |

## Providers (atomic)

| Provider | Path |
|---|---|
| JWT Bearer | [providers/jwt/SKILL.md](providers/jwt/SKILL.md) |
| API Key | [providers/api-key/SKILL.md](providers/api-key/SKILL.md) |
| HTTP Basic | [providers/basic/SKILL.md](providers/basic/SKILL.md) |
| Cognito | [providers/cognito/SKILL.md](providers/cognito/SKILL.md) |

## Templates

- [templates/program-auth.cs](templates/program-auth.cs)
- [templates/appsettings-authentication.json](templates/appsettings-authentication.json)

## Output bắt buộc

- `AddJarvisAuthentication(config, auth => { AddCore* })` + `UseAuthentication` / `UseAuthorization`
- `appsettings` section `Authentication` (schema đúng: API Key `KeyName`+`Key`, Basic `Users`, JWT `Authority`/`IssuerSigningKeys`)
- Protected endpoint trả 401 khi thiếu credential (validate)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [hoangnh2412](https://github.com/hoangnh2412)
- **Source:** [hoangnh2412/ai-skills](https://github.com/hoangnh2412/ai-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-hoangnh2412-ai-skills-authentication-dotnet
- Seller: https://agentstack.voostack.com/s/hoangnh2412
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
