Altinn / app-lib-dotnet

Libraries used in Altinn Apps
BSD 3-Clause "New" or "Revised" License
8 stars 10 forks source link

Implement IMaskinportenClient interface #602

Closed danielskovli closed 1 month ago

danielskovli commented 4 months ago

Description

In relation to #492, app-lib-dotnet needs to expose an IMaskinportenClient interface along with an implementation.

Assuming that the app developer has configured the required Maskinporten scopes via Altinn Studio (publish page), the app should be able to receive an IMaskinportenClient instance at runtime. This instance will handle Maskinporten authentication and expose a .GetAccessToken method or simila; for use with HttpClient calls to protected APIs.

Additional Information

Should we also expose a factory method that returns a pre-authenticated HttpClient instance? If so, consider IHttpClientFactory [1, 2]

danielskovli commented 4 months ago

Note to self: DelegatingHandler -> https://stackoverflow.com/a/61410855/9589714

RonnyB71 commented 4 months ago

We should probably look into existing applications using Maskinporten ensuring we have one consistent way moving forward. In App.Core we have used a package Altinn.ApliClients.Maskinporten and we should make a decision whether we use this or not. And if not we should deprecated it and remove it i V9.

danielskovli commented 3 months ago

In App.Core we have used a package Altinn.ApliClients.Maskinporten and we should make a decision whether we use this or not.

Without being able to absolutely confirm this, the team has indicated on multiple occasions that owning the Maskinporten integration completely and absorbing the relevant code into Altinn.App.Core is preferred.

danielskovli commented 2 months ago

WIP project at https://github.com/danielskovli/maskinporten-authentication-dotnet

To become a PR with app-lib-dotnet once most of the creases are ironed out.

danielskovli commented 2 months ago

Implementation: https://github.com/Altinn/app-lib-dotnet/pull/669