• Joined on 2026-06-30

PolarisLib (1.9.0)

Published 2026-08-26 00:10:11 +00:00 by neto

Installation

dotnet nuget add source --name neto --username your_username --password your_token https://gitea.jbsn.com.br/api/packages/neto/nuget/index.json
dotnet add package --source neto --version 1.9.0 PolarisLib

About this package

No description

English | Portuguese

Polaris

What is it?

PolarisLib is a lightweight client library and helper NuGet package that complements the Polaris API (https://github.com/NetoBatista/polaris_api). It provides reusable services, integrations and extension methods to simplify adding authentication and authorization to ASP.NET projects. Install the package to register authentication services, optional generated controllers, token utilities and provider integrations (Firebase, Google OAuth2) so your application can authenticate users against a Polaris backend.

How does it work?

PolarisLib exposes an extension method AddPolarisAuthorization(IConfiguration) that registers the library's services into the application's dependency injection container. Behavior is controlled by configuration under the Polaris section in appsettings.json (for example: Key, GenerateController, PrefixRouter, and provider-specific settings).

When enabled, the library can dynamically generate controller routes (controlled by GenerateController) under the configured prefix (PrefixRouter) and wire up:

  • Authentication services (e.g. PolarisAuthenticationService) and handlers for request flows
  • An integration client (PolarisIntegration) to call the Polaris API
  • Token utilities (TokenUtil) for creating and validating JWTs
  • Adapters for external providers (Firebase, Google OAuth2) and helper request/response models

Typical usage:

  1. Add the NuGet package to your project.
  2. Call builder.Services.AddPolarisAuthorization(builder.Configuration) in Program.cs.
  3. Configure the required options in appsettings.json (at minimum the Polaris:Key).

At runtime the library registers the services and (optionally) controller endpoints that your application uses to authenticate users, generate/refresh tokens, and integrate with the Polaris authentication API and external providers.

Getting Started

Generate package using the command:

dotnet pack --configuration Release --output .

push the package using the command:

dotnet nuget push "PolarisLib.1.9.0.nupkg" --source "gitea"

create in your project the file nuget.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="gitea" value="https://gitea.jbsn.com.br/api/packages/neto/nuget/index.json" />
    </packageSources>
    <packageSourceCredentials>
        <gitea>
            <add key="Username" value="neto" />
            <add key="ClearTextPassword" value="1891eea97d10b1ae3f038578205c856affdcc2d0" />
        </gitea>
    </packageSourceCredentials>
</configuration>

after this, execute the command:

dotnet add package PolarisLib

How to use ?

In the file program.cs add the code:

builder.Services.AddPolarisAuthorization(builder.Configuration);

To configure authentication, put the options in appSettings.json

Minimum configuration required

"Polaris": {
  "Key": "a6c9fe83-dcde-4495-98cc-e218a22924a2"
}

Complete configuration

"Polaris": {
  "Key": "a6c9fe83-dcde-4495-98cc-e218a22924a2",
  "GenerateController": true,
  "PrefixRouter": "api",
  "Authentication": {
    "OnGenerateCode": {
      "CreateUserAutomatic": false
    },
    "GoogleOAuth2": {
        "ClientId": "a8b7857a-492e-45da-adad-43ac65acbec1"
    },
    "Firebase" : {
      "AppId": "da1c3f06-0e5f-44c6-a38a-5ec6b02a0094",
      "JsonCredencials": "f7dfa792-815c-4bf8-aae5-db0f2cdebfcc"
    }
  },
  "User": {
    "OnCreate": {
      "Roles": [
        "ROLE1", 
        "ROLE2"
      ]
    }
  }
}

Dependencies

ID Version Target Framework
Microsoft.AspNetCore.Authentication.JwtBearer 10.0.0 net10.0
Microsoft.AspNetCore.Routing 2.3.0 net10.0
Details
NuGet
2026-08-26 00:10:11 +00:00
5
JBSN
27 KiB
Assets (2)
Versions (3) View all
1.9.0 2026-08-26
1.8.14 2026-08-25
1.8.13 2026-06-30