Add mTLS authentication via Digipost mIdP to use JWT in client API calls - #372
Add mTLS authentication via Digipost mIdP to use JWT in client API calls#372sondrew wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review this pull request because all changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.
There was a problem hiding this comment.
Copilot wasn't able to review this pull request because all changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.
| @@ -0,0 +1,362 @@ | |||
| package no.digipost.signature.client.core.internal.http; | |||
|
|
|||
| import com.fasterxml.jackson.core.*; | |||
There was a problem hiding this comment.
Aha, didn't know. Fikset IntelliJ config og queue'a import fix
|
Denne kalles én gang, i Men biblioteket støtter uttrykkelig per-jobb sender-override — ment for meglere ("broker") som sender på vegne av flere organisasjoner. Se f.eks. Konkret feilscenario Klienten har allerede hentet/cachet et access-token med scope Konsekvens
Mulige fikser
|
@Smurfz87 |
|
@Smurfz87 Etter å ha undersøkt en del mer rundt hvordan dette funker, så trengs det ikke dynamisk endring av scope alikevel. I signering-api så ligger ikke tilgangsstyringen/knytningen som tillater at en virksomhet kan sende på vegne av en annen i mIDP/Nyva, og i signering er virksomhet og konto 1-til-1. Så for en gitt client man oppretter i Nyva, så kan det kun finnes én brokerId/senderId, men denne brokerId'en kan sende på vegne av andre vha |
💰 Funksjonell beskrivelse av endringen
Adds OAuth 2.0 client-credentials authentication as an alternative to authenticating with the organization certificate directly. The client presents its certificate over mTLS to Digipost's identity provider (mIdP) to obtain an access token, then authenticates API requests with that token as a bearer token. The functionality is backwards compatible: without jwtAuthentication(..) nothing changes.
This enables customers to use our clients without having to pay for an expensive enterprise certificate, and being able to use that certificate across multiple services (signing, digipost, etc). mIdP accepts certificates issued by Digipost's own certificate issuer, and the same certificate works across Digipost services. The equivalent change is done for all java/dotnet clients for digipost and signature. A certificate is still required — this changes which certificate is acceptable, not whether one is needed. It authenticates to mIdP and signs ASiC-E bundles (an XAdES signature over the document hashes, which needs the private key and embeds the certificate chain).
🏆 Interessante highlights
🤷♀️ Anbefalt fremgangsmåte
certificate --mTLS--> mIdP token endpoint --> access token
access token --Bearer--> Signering API (no client certificate)
certificate --> ASiC-E document signing (unchanged)
Public API
endpoint over mTLS, authenticated with the organization certificate:
scope=signering-api:, resource=.
Testing