laget.PskAuthentication.Mvc 2.3.8

Prefix Reserved
dotnet add package laget.PskAuthentication.Mvc --version 2.3.8
                    
NuGet\Install-Package laget.PskAuthentication.Mvc -Version 2.3.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="laget.PskAuthentication.Mvc" Version="2.3.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="laget.PskAuthentication.Mvc" Version="2.3.8" />
                    
Directory.Packages.props
<PackageReference Include="laget.PskAuthentication.Mvc" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add laget.PskAuthentication.Mvc --version 2.3.8
                    
#r "nuget: laget.PskAuthentication.Mvc, 2.3.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package laget.PskAuthentication.Mvc@2.3.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=laget.PskAuthentication.Mvc&version=2.3.8
                    
Install as a Cake Addin
#tool nuget:?package=laget.PskAuthentication.Mvc&version=2.3.8
                    
Install as a Cake Tool

laget.PskAuthentication

Generic implementation of Secure Pre-Shared Key (PSK) Authentication for laget.se using AES.

Nuget Nuget

Nuget Nuget

Nuget Nuget

Configuration

This example is shown using Autofac since this is the go-to IoC for us.

public class OptionModule : Module
{
    readonly IConfiguration _configuration;

    public OptionModule(IConfiguration configuration)
    {
        _configuration = configuration;
    }

    protected override void Load(ContainerBuilder builder)
    {
        builder.Register(c => new PskAuthenticationAttribute(new PskAuthenticationOptions
        {
            Key = _configuration.GetValue<string>("Security:Key"),
            IV = _configuration.GetValue<string>("Security:IV"),
            Salt = _configuration.GetValue<string>("Security:Salt"),
            Secret = _configuration.GetValue<string>("Security:Secret")
        })).AsSelf();
    }
}

appsettings.json

"Security": {
  "Key": "...",
  "IV": "...",
  "Salt": "...",
  "Secret": "..."
}

Usage

Controller

[PskAuthentication]
public class SomeController : ControllerBase
{
}

Aes

You can generate the necessary Aes properties via the code below or visit https://rextester.com/RMKPPK46300

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Security.Cryptography;
    
namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var aes = Aes.Create();
            aes.Mode = CipherMode.CBC;
            aes.Padding = PaddingMode.PKCS7;
            aes.GenerateIV();
            aes.GenerateKey();
            
            Console.WriteLine(Convert.ToBase64String(aes.IV));
            Console.WriteLine(Convert.ToBase64String(aes.Key));
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.8 209 10/30/2024
2.2.5 415 2/9/2024
2.1.4 305 1/20/2024
2.1.3 237 9/28/2023
2.0.1 216 9/19/2023
1.0.25 398 3/10/2023
1.0.24 327 3/10/2023
1.0.23 457 12/5/2022
1.0.22 529 10/27/2022
1.0.21 583 7/8/2022
1.0.20 610 2/9/2022
1.0.18 608 8/16/2021
1.0.17 537 7/5/2021
1.0.16 582 4/6/2021
1.0.15 533 3/5/2021
1.0.14 625 2/1/2021
1.0.13 904 12/23/2020
1.0.12 568 12/22/2020
1.0.11 642 12/16/2020
1.0.10 659 12/12/2020
1.0.9 669 12/12/2020
1.0.8 586 12/11/2020