![]() |
VOOZH | about |
dotnet add package Arc4u.Standard.OAuth2.AspNetCore --version 8.3.2
NuGet\Install-Package Arc4u.Standard.OAuth2.AspNetCore -Version 8.3.2
<PackageReference Include="Arc4u.Standard.OAuth2.AspNetCore" Version="8.3.2" />
<PackageVersion Include="Arc4u.Standard.OAuth2.AspNetCore" Version="8.3.2" />Directory.Packages.props
<PackageReference Include="Arc4u.Standard.OAuth2.AspNetCore" />Project file
paket add Arc4u.Standard.OAuth2.AspNetCore --version 8.3.2
#r "nuget: Arc4u.Standard.OAuth2.AspNetCore, 8.3.2"
#:package Arc4u.Standard.OAuth2.AspNetCore@8.3.2
#addin nuget:?package=Arc4u.Standard.OAuth2.AspNetCore&version=8.3.2Install as a Cake Addin
#tool nuget:?package=Arc4u.Standard.OAuth2.AspNetCore&version=8.3.2Install as a Cake Tool
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.
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.
When the call to the business layer is a success, depending on the result, different codes will be returned.
The return code is 204 NoContent.
The return code is 200 Ok or 201 Created.
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>);
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);
When an error occurs, the business layer will return a Result object with the error information.
Different cases could happen:
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.
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).
When a problemDetailError is returned, a 500 InternalServerError is returned with a ProblemDetails message explaining the error when no specific StatusCode is given.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
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 |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.3.2 | 510 | 7/18/2025 |
| 8.3.2-preview08 | 387 | 6/11/2025 |
| 8.3.2-preview07 | 387 | 6/10/2025 |
| 8.3.2-preview06 | 242 | 6/3/2025 |
| 8.3.2-preview05 | 181 | 5/31/2025 |
| 8.3.2-preview04 | 232 | 5/25/2025 |
| 8.3.2-preview03 | 330 | 5/13/2025 |
| 8.3.2-preview02 | 243 | 5/10/2025 |
| 8.3.2-preview01 | 285 | 5/7/2025 |
| 8.3.1 | 394 | 5/5/2025 |
| 8.3.0 | 329 | 5/4/2025 |
| 8.3.0-preview04 | 218 | 5/3/2025 |
| 8.3.0-preview03 | 193 | 2/15/2025 |
| 8.3.0-preview02 | 202 | 11/14/2024 |
| 8.3.0-preview01 | 294 | 8/30/2024 |
| 8.2.1 | 1,673 | 11/10/2024 |
| 8.2.1-preview01 | 265 | 11/9/2024 |
| 8.2.0 | 1,892 | 8/16/2024 |
| 8.2.0-preview31 | 300 | 8/16/2024 |
| 8.2.0-preview30 | 307 | 8/1/2024 |