AuthModule 1.0.9

AuthModule

Kullanıcı JWT Token bilgilerini ve ApiKey bilgilerini kontrol eden modül

Projeye Ekleme

Windows : %appdata%\NuGet\NuGet.Config Lİnux Veya Mac : ~/.nuget/NuGet/NuGet.Config

  ...
<packageSources>
    ...
    <add key="localnuget.roboliza.com" value="http://172.16.33.42:5011/v3/index.json" protocolVersion="3" allowInsecureConnections="true" />
    <add key="nuget.roboliza.com" value="https://nuget.roboliza.com/v3/index.json" protocolVersion="3" allowInsecureConnections="true" /> 
</packageSources>

Dockerfile Dosyasına Ekleme

RUN dotnet nuget add source http://172.16.33.42:5011/v3/index.json
RUN dotnet nuget add source https://nuget.roboliza.com/v3/index.json

Kullanım

Program.cs

string jwtSecretKey = Environment.GetEnvironmentVariable("JWT_SECRET_KEY");

builder.Services.AddAuthModule(jwtSecretKey);

Yetki tipine göre istekleri kabul etme

[Route("AddAros")]
[CheckAuthType(AuthType.Token)] // Sadece Token ile gelen istekleri kabul eder
[HttpPost]
public async Task<IActionResult> AddAros([FromBody] PostAddArosDto model)
{
    ...
}

[Route("AddRobot")]
[CheckAuthType(AuthType.ApiKey)] // Sadece ApiKey ile gelen istekleri kabul eder
[HttpPost]
public async Task<IActionResult> AddRobot([FromBody] PostAddRobotDto model)
{
    ...
}

[Route("RobotInfo")]
[CheckAuthType(AuthType.Token,AuthType.ApiKey)] // Her iki yetki tipinde gelen istekleri kabul eder
[HttpGet]
public async Task<IActionResult> RobotInfo([FromQuery] GetRobotInfoDto model)
{
    ...
}

Kullanıcı rolüne göre istekleri kabul etme

[Route("AddArosSchema")]
[CheckUserType(UserType.SuperAdmin, UserType.Tester, UserType.Developer)] // Kullanıcı rollerine göre gelen istekleri kabul eder
[HttpPost]
public async Task<IActionResult> AddArosSchema([FromQuery] PostAddArosSchemaDto model)
{
    ...
}

Kullanıcı izinlerine göre erişim kontrolü yapmak için [UserPermission] attribute'unu controller'da veya action'da kullanabilirsiniz.

[Route("TestPermission")]
[UserPermission] // Bu endpointte kullanıcı izin kontrolü yapılır
[HttpGet]
public async Task<IActionResult> TestPermission()
{
    ...
}

Belirli bir controller üzerinde de kullanabilirsiniz:

[UserPermission]
[ApiController]
[Route("[controller]")]
public class PermissionTestController : ControllerBase
{
    [HttpGet("List")]
    public IActionResult List()
    {
        // Kullanıcı izin kontrolü burada da uygulanır
        ...
    }
}

[UserPermission] yalnızca bu attribute tanımlanan controller veya action'da devreye girer. Redis'te izni olmayan kullanıcıların erişimi reddedilir.

Showing the top 20 packages that depend on AuthModule.

Packages Downloads
LogModule
Package Description
312
LogModule
Package Description
255
LogModule
Package Description
161
LogModule
Package Description
127
LogModule
Package Description
108
LogModule
Package Description
54
LogModule
Package Description
29
LogModule
Package Description
25
LogModule
Package Description
23
LogModule
Package Description
21
LogModule
Package Description
20

Version Downloads Last updated
1.0.9 85 03/18/2026
1.0.8 86 02/26/2026
1.0.7 352 01/15/2025
1.0.6 424 01/15/2025
1.0.5 66 01/13/2025