Arc4u.Standard.OAuth2.AspNetCore 8.3.2

Prefix Reserved
dotnet add package Arc4u.Standard.OAuth2.AspNetCore --version 8.3.2
                    
NuGet\Install-Package Arc4u.Standard.OAuth2.AspNetCore -Version 8.3.2
                    
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="Arc4u.Standard.OAuth2.AspNetCore" Version="8.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Arc4u.Standard.OAuth2.AspNetCore" Version="8.3.2" />
                    
Directory.Packages.props
<PackageReference Include="Arc4u.Standard.OAuth2.AspNetCore" />
                    
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 Arc4u.Standard.OAuth2.AspNetCore --version 8.3.2
                    
#r "nuget: Arc4u.Standard.OAuth2.AspNetCore, 8.3.2"
                    
#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 Arc4u.Standard.OAuth2.AspNetCore@8.3.2
                    
#: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=Arc4u.Standard.OAuth2.AspNetCore&version=8.3.2
                    
Install as a Cake Addin
#tool nuget:?package=Arc4u.Standard.OAuth2.AspNetCore&version=8.3.2
                    
Install as a Cake Tool

Arc4u.Standard.OAuth2.AspNetCore

Core framework to integrate OAuth2 and creation of the principal in asp net core.

As it is a AspNetCore library, it is based on the Microsoft.AspNetCore.Authentication and Microsoft.AspNetCore.Authentication.OAuth libraries.

Do not use this package in other contexts than AspNetCore.

ProblemDetails extension

When working with the Results feature in Arc4u, the Rest Api controller will return a ProblemDetails object when an error occurs.

The idea is from a controller endpoint to call the business layer and return the result to the client. The business layer will return a Result object that can be converted to an ActionResult object.

    return await bl.DoSomethingAsync()
                   .ToActionOkResultAsync();

Different situations, different HttpStatusCodes can be returned.

Success path:

When the call to the business layer is a success, depending on the result, different codes will be returned.

Result:

The return code is 204 NoContent.

Result<T>

The return code is 200 Ok or 201 Created.

200 Ok HTTP GET

What to return when the value is null?
On internet, it is not clear what to return when the value is null. Some say to return a 204 NoContent, others say to return a 200 OK with a null value.
I find personaly than returning a 204 NoContent is more appropriate. The client knows that the call was successful but there is no content to return.

If you are using proxy code generator like NSwagStudio, this situation is not managed like I would expect. If you return a 200 Ok when you have a value and a 204 NoContent when the value is null, the proxy code generator will return the value when there is a value but will manage the 204 NoContent as an error! To avoid this today, I return a 200 Ok with a null value. The client will have to manage the null value.

It is possible to override the default behavior by informing the extension method to return another code when the value is null.

    return await bl.DoSomethingAsync(id)
                   .ToActionResultAsync(() => StatusCode(StatusCodes.Status204NoContent));

Mapping to a Dto is also possible. The mapper is a function and can be AutoMapper or any other mapper.

    return await bl.DoSomethingAsync(id)
                   .ToActionResultAsync(mapper.Map<ContractDto>);
201 Created HTTP POST

When the result is a 201 Created, the location header is set to the location of the created resource.

To handle this specific situation, the extension method ToActionCreatedResultAsync is available. The method expect a Uri to set the location correctly.
The need to split the call in two steps is to allow the business layer to return the result and the controller to set the location header.
If you do this in one step, the location is captured when the fluent Api is built and the location will never be updated when the ToActionCreatedResultAction is called!


        Uri? location = null;

        var result = await bl.DoSomethingAsync(dto, cancellation)
                                         .OnSuccess((contract) => location = new Uri(Url.ActionLink("GetById", "Contract", new { id = contract.Id })!))
                                         .ConfigureAwait(false);

        return await result.ToActionCreatedResultAsync(location, mapper.Map<ContractDto>)
                           .ConfigureAwait(false);

Error path:

When an error occurs, the business layer will return a Result object with the error information.

Different cases could happen:

  • An exception was thrown.
  • A validation error occured.
  • A Problem occured.
Exception

When an exception is thrown, a 500 InternalServerError is returned with a ProblemDetails message explaining that the exception is log with an activyId. There is no more explanation about the exception to avoid leaking information.

Validation error

When some parameters or Dto is given to a controller, code will validate the inputs.
If the validation fails, a 422 UnprocessableEntity is returned with a ValidationProblemDetails message explaining the validation errors.
The code of the validation error is used to categorrized the errors (they are grouped by code).

Problem

When a problemDetailError is returned, a 500 InternalServerError is returned with a ProblemDetails message explaining the error when no specific StatusCode is given.

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 is compatible.  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 (3)

Showing the top 3 NuGet packages that depend on Arc4u.Standard.OAuth2.AspNetCore:

Package Downloads
Arc4u.Standard.OAuth2.AspNetCore.Msal

Core Framework used in AspNetCore to authenticate user based on Msal.

Arc4u.Standard.OAuth2.AspNetCore.Authentication

Package Description

Arc4u.Standard.OAuth2.AspNetCore.Adal

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.3.2 423 7/18/2025
8.3.2-preview08 352 6/11/2025
8.3.2-preview07 355 6/10/2025
8.3.2-preview06 210 6/3/2025
8.3.2-preview05 147 5/31/2025
8.3.2-preview04 201 5/25/2025
8.3.2-preview03 302 5/13/2025
8.3.2-preview02 211 5/10/2025
8.3.2-preview01 257 5/7/2025
8.3.1 344 5/5/2025
8.3.0 277 5/4/2025
8.3.0-preview04 184 5/3/2025
8.3.0-preview03 157 2/15/2025
8.3.0-preview02 169 11/14/2024
8.3.0-preview01 260 8/30/2024
8.2.1 1,418 11/10/2024
8.2.1-preview01 239 11/9/2024
8.2.0 1,747 8/16/2024
8.2.0-preview31 268 8/16/2024
8.2.0-preview30 282 8/1/2024
8.2.0-preview29 201 7/25/2024
8.2.0-preview28 185 7/25/2024
8.2.0-preview27 262 6/28/2024
8.2.0-preview26 290 6/27/2024
8.2.0-preview25 263 6/26/2024
8.2.0-preview24 256 6/9/2024
8.2.0-preview23 350 5/29/2024
8.2.0-preview22 283 5/26/2024
8.2.0-preview21 242 5/22/2024
8.2.0-preview20 282 5/19/2024
8.2.0-preview19 216 5/18/2024
8.2.0-preview18 199 5/12/2024
8.2.0-preview17 185 5/12/2024
8.2.0-preview16 205 5/12/2024
8.2.0-preview15 216 5/11/2024
8.2.0-preview14 178 5/10/2024
8.2.0-preview13 215 5/9/2024
8.2.0-preview12 251 5/8/2024
8.2.0-preview11 254 5/7/2024
8.2.0-preview10 208 5/5/2024
8.2.0-preview09 238 5/4/2024
8.2.0-preview08 212 4/25/2024
8.2.0-preview07 245 4/23/2024
8.2.0-preview06 253 4/23/2024
8.2.0-preview05 225 4/21/2024
8.2.0-preview04 236 4/20/2024
8.2.0-preview03 213 4/17/2024
8.2.0-preview02 255 4/12/2024
8.2.0-preview01 255 4/11/2024
8.1.0 2,975 2/7/2024
8.1.0-preview10 214 2/6/2024
8.1.0-preview09 233 1/29/2024
8.1.0-preview08 265 1/9/2024
8.1.0-preview07 253 12/31/2023
8.1.0-preview06 254 12/30/2023
8.1.0-preview05 256 12/24/2023
8.1.0-preview04 240 12/23/2023
8.1.0-preview03 223 12/20/2023
8.1.0-preview02 277 12/20/2023
8.1.0-preview01 258 12/19/2023
8.0.0 391 12/15/2023
8.0.0-preview01 250 12/14/2023
6.1.22.1-preview06 275 11/25/2023
6.1.22.1-preview05 224 11/24/2023
6.1.22.1-preview04 291 11/20/2023
6.1.22.1-preview03 273 11/17/2023
6.1.22.1-preview02 213 11/17/2023
6.1.22.1-preview01 205 11/16/2023
6.1.21.1-preview04 228 10/10/2023
6.1.21.1-preview03 151 10/10/2023
6.1.21.1-preview02 182 10/5/2023
6.1.21.1-preview01 152 9/21/2023
6.1.20.1-preview03 176 8/31/2023
6.1.20.1-preview02 308 8/14/2023
6.1.20.1-preview01 292 8/13/2023
6.1.18.1 1,014 8/18/2023
6.0.14.3-preview56 275 8/7/2023
6.0.14.3-preview55 252 8/4/2023
6.0.14.3-preview54 321 8/3/2023
6.0.14.3-preview53 296 8/1/2023
6.0.14.3-preview52 301 7/26/2023
6.0.14.3-preview51 301 7/26/2023
6.0.14.3-preview50 306 7/19/2023
6.0.14.3-preview49 294 7/19/2023
6.0.14.3-preview48 311 7/12/2023
6.0.14.3-preview47 289 7/6/2023
6.0.14.3-preview46 328 7/3/2023
6.0.14.3-preview45 315 6/24/2023
6.0.14.3-preview44 299 6/18/2023
6.0.14.3-preview43 270 6/18/2023
6.0.14.3-preview42 288 6/14/2023
6.0.14.3-preview41 323 6/12/2023
6.0.14.3-preview40 283 6/9/2023
6.0.14.3-preview39 293 6/8/2023
6.0.14.3-preview38 296 5/30/2023
6.0.14.3-preview37 354 5/29/2023
6.0.14.3-preview36 358 5/26/2023
6.0.14.3-preview35 333 5/23/2023
6.0.14.3-preview34 288 5/22/2023
6.0.14.3-preview33 354 5/19/2023
6.0.14.3-preview32 320 5/19/2023
6.0.14.3-preview31 312 5/18/2023
6.0.14.3-preview30 322 5/12/2023
6.0.14.3-preview29 330 5/12/2023
6.0.14.3-preview28 354 5/10/2023
6.0.14.3-preview27 345 5/8/2023
6.0.14.3-preview26 361 5/7/2023
6.0.14.3-preview25 338 5/3/2023
6.0.14.3-preview24 316 4/29/2023
6.0.14.3-preview23 338 4/28/2023
6.0.14.3-preview22 330 4/27/2023
6.0.14.3-preview21 341 4/26/2023
6.0.14.3-preview20 338 4/24/2023
6.0.14.3-preview19 361 4/18/2023
6.0.14.3-preview18 360 4/17/2023
6.0.14.3-preview17 360 4/16/2023
6.0.14.3-preview16 305 4/14/2023
6.0.14.3-preview15 339 4/14/2023
6.0.14.3-preview14 306 4/11/2023
6.0.14.3-preview13 410 4/3/2023
6.0.14.3-preview12 313 4/1/2023
6.0.14.3-preview11 331 4/1/2023
6.0.14.3-preview10 353 3/30/2023
6.0.14.3-preview09 332 3/29/2023
6.0.14.3-preview08 375 3/25/2023
6.0.14.3-preview07 354 3/24/2023
6.0.14.3-preview06 351 3/19/2023
6.0.14.3-preview05 333 3/17/2023
6.0.14.3-preview04 314 3/15/2023
6.0.14.3-preview03 293 3/15/2023
6.0.14.3-preview02 316 3/14/2023
6.0.14.3-preview01 298 3/11/2023
6.0.14.2 1,786 3/8/2023
6.0.14.2-preview02 329 3/4/2023
6.0.14.2-preview01 309 3/3/2023
6.0.14.1 559 2/17/2023
6.0.14.1-preview02 355 2/16/2023
6.0.14.1-preview01 331 2/15/2023
6.0.13.1 542 2/15/2023
6.0.12.1 581 2/15/2023
6.0.11.2 575 2/15/2023
6.0.11.2-preview03 304 2/14/2023
6.0.11.2-preview02 337 2/13/2023
6.0.11.2-preview01 320 2/12/2023
6.0.11.1 3,505 1/11/2023
6.0.11.1-preview11 300 1/10/2023
6.0.11.1-preview10 333 1/10/2023
6.0.11.1-preview09 356 1/8/2023
6.0.11.1-preview08 346 1/4/2023
6.0.11.1-preview07 362 1/3/2023
6.0.11.1-preview06 335 1/3/2023
6.0.11.1-preview05 334 1/2/2023
6.0.11.1-preview04 293 1/2/2023
6.0.11.1-preview03 308 12/10/2022
6.0.11.1-preview02 300 11/15/2022
6.0.11.1-preview01 434 11/11/2022
6.0.9.3 3,272 11/8/2022
6.0.9.2 865 9/27/2022
6.0.9.1 4,402 9/17/2022
6.0.8.4 797 11/8/2022
6.0.8.3 922 9/27/2022
6.0.8.2 790 9/16/2022
6.0.8.1 793 9/7/2022
6.0.8.1-preview02 305 9/5/2022
6.0.8.1-preview01 348 8/18/2022
6.0.6.1-preview03 397 6/25/2022
6.0.6.1-preview02 355 6/15/2022
6.0.6.1-preview01 318 6/15/2022
6.0.5.1-preview01 597 5/10/2022
6.0.4.1-preview04 345 5/7/2022
6.0.4.1-preview03 377 4/27/2022
6.0.4.1-preview02 331 4/27/2022
6.0.4.1-preview01 365 4/24/2022
5.0.17.3 858 9/19/2022
5.0.17.3-preview01 363 9/16/2022
5.0.17.2 802 9/1/2022
5.0.17.2-preview07 349 8/29/2022
5.0.17.2-preview06 320 8/24/2022
5.0.17.2-preview05 325 8/24/2022
5.0.17.2-preview04 313 8/23/2022
5.0.17.2-preview03 322 8/22/2022
5.0.17.2-preview02 313 8/22/2022
5.0.17.2-preview01 336 8/17/2022
5.0.17.1 859 5/30/2022
5.0.16.1 857 5/7/2022
5.0.16.1-preview02 380 4/17/2022
5.0.16.1-preview01 356 4/14/2022
5.0.15.1-preview07 371 4/2/2022
5.0.15.1-preview06 330 4/1/2022
5.0.15.1-preview05 367 3/30/2022
5.0.15.1-preview04 365 3/27/2022
5.0.15.1-preview03 363 3/18/2022
5.0.15.1-preview02 381 3/13/2022
5.0.15.1-preview01 371 3/13/2022
5.0.14.1-preview9 348 3/1/2022
5.0.14.1-preview7 349 2/23/2022
5.0.14.1-preview6 387 2/20/2022
5.0.14.1-preview5 364 2/20/2022
5.0.14.1-preview4 359 2/19/2022
5.0.14.1-preview3 388 2/19/2022
5.0.14.1-preview2 360 2/10/2022
5.0.14.1-preview13 337 3/11/2022
5.0.14.1-preview12 370 3/9/2022
5.0.14.1-preview11 376 3/7/2022
5.0.14.1-preview10 368 3/2/2022
5.0.14.1-preview1 358 2/9/2022
5.0.13.1-preview4 376 1/30/2022
5.0.13.1-preview3 383 1/29/2022
5.0.13.1-preview2 370 1/29/2022
5.0.13.1-preview1 360 1/29/2022
5.0.11.2 2,344 10/20/2021
5.0.11.2-preview1 447 10/19/2021
5.0.11.1 699 10/19/2021
5.0.11.1-preview4 373 10/19/2021
5.0.11.1-preview3 456 10/18/2021
5.0.11.1-preview2 480 10/17/2021
5.0.11.1-preview1 429 10/16/2021
5.0.10.3 697 9/30/2021
5.0.10.2 730 9/30/2021
5.0.10.1 687 9/28/2021
5.0.9.1-preview1 400 9/1/2021
5.0.8.2 519 8/19/2021
5.0.8.1 561 8/11/2021
5.0.6.4 584 7/13/2021
5.0.6.3 1,076 7/10/2021
5.0.6.2 555 7/7/2021
5.0.6.1 998 6/29/2021
5.0.6.1-rc16 411 6/21/2021
5.0.6.1-rc15 415 6/20/2021
5.0.6 2,215 5/21/2021
5.0.5 612 5/21/2021
1.0.0 306 5/18/2024