Nexttag.Auth
1.1.0
dotnet add package Nexttag.Auth --version 1.1.0
NuGet\Install-Package Nexttag.Auth -Version 1.1.0
<PackageReference Include="Nexttag.Auth" Version="1.1.0" />
<PackageVersion Include="Nexttag.Auth" Version="1.1.0" />
<PackageReference Include="Nexttag.Auth" />
paket add Nexttag.Auth --version 1.1.0
#r "nuget: Nexttag.Auth, 1.1.0"
#:package Nexttag.Auth@1.1.0
#addin nuget:?package=Nexttag.Auth&version=1.1.0
#tool nuget:?package=Nexttag.Auth&version=1.1.0
Nexttag.Auth
Contratos universais de autenticação compartilhados pelas libs
Nexttag.Auth.*. Hoje:ICurrentUserProvider(quem é o usuário do request atual) — provedor-agnóstico (Jwt, Identity, Keycloak, NextAuth implementam).
ℹ️ v1.1.0: o contrato de emissão de token (
IJwtService) saiu desta base e vive emNexttag.Auth.Jwt— emitir token é mecanismo específico (Keycloak/NextAuth não emitem, só validam). O namespace segueNexttag.Auth, então o código consumidor não muda, só recompila.
Instalar
dotnet add package Nexttag.Auth
Requer .NET 10.
Registrar (Program.cs)
Este pacote não tem registro próprio — é instalado como dependência transitiva de Nexttag.Auth.Jwt, Nexttag.Auth.Identity, Nexttag.Auth.Keycloak ou Nexttag.Auth.NextAuth. Não é necessário chamá-lo diretamente.
Configurar
Sem configuração obrigatória.
Usar
Para emitir tokens (
IJwtService), use o pacoteNexttag.Auth.Jwt(veja o README de lá). Esta base expõe só o contrato universal abaixo.
ICurrentUserProvider
Lê os claims do usuário autenticado no request atual:
public class MeuController(ICurrentUserProvider usuario)
{
public IActionResult Info()
{
var id = usuario.UsuarioId; // Guid?
var nome = usuario.Nome; // string?
var email = usuario.Email; // string?
var claim = usuario.GetClaim("tenantId"); // string?
return Ok(new { id, nome, email });
}
}
Receitas
Injetar em qualquer serviço de domínio:
public class PedidoService(ICurrentUserProvider usuarioAtual, IPedidoRepository repo)
{
public async Task CriarPedido(PedidoDto dto)
{
var autorId = usuarioAtual.UsuarioId
?? throw new UnauthorizedAccessException();
await repo.AdicionarAsync(new Pedido { AutorId = autorId, ... });
}
}
Notas
ICurrentUserProviderretornanullquando não há usuário autenticado — trate o caso.- A implementação concreta (
CurrentUserProvider) é registrada automaticamente porAddNexttagJwtAuth. - Emissão de token (
IJwtService) agora vive emNexttag.Auth.Jwt(namespaceNexttag.Authmantido).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Nexttag.Auth:
| Package | Downloads |
|---|---|
|
Nexttag.Auth.Jwt
Implementação JWT: geração de tokens, leitura de cookie HttpOnly, CurrentUserProvider |
|
|
Nexttag.Auth.Identity.Google
Login social com Google para ASP.NET Identity (Nexttag.Auth.Identity): valida o id_token do Google, acha-ou-cria o usuario e emite JWT local. Sem Firebase. |
|
|
Nexttag.Auth.Identity
ASP.NET Identity integrado: login, registro, roles — banco local sem serviço externo |
|
|
Nexttag.Auth.NextAuth
Client HTTP para NextAuth API |
GitHub repositories
This package is not used by any popular GitHub repositories.
1.1.0: IJwtService movido para Nexttag.Auth.Jwt (emissao de token e mecanismo especifico, nao contrato universal). O namespace segue Nexttag.Auth — codigo consumidor nao muda, so recompila. A base agora expoe apenas ICurrentUserProvider.