Backend & Security Engineer: Integrating Singapore Singpass & MyInfo v4 (FAPI 2.0 OIDC, DPoP & JWE) in Go
Fintech, insurance, and digital healthcare platforms operating in Singapore rely on Singpass Authentication and MyInfo to verify national digital identities and pre-fill government-verified KYC attributes. Unlike basic consumer OAuth 2.0 providers that accept simple client secrets, Singpass v4/v5 enforces the Financial-grade API (FAPI 2.0) security profile: asymmetric private_key_jwt client assertions (ES256), Proof-of-Possession (DPoP, RFC 9449), Pushed Authorization Requests (PAR), and nested JWE-encrypted + JWS-signed ID/person tokens. As a Backend Engineer, I implement production Singpass and MyInfo gateways in Go (Golang).
1. Generating `private_key_jwt` Client Assertions & DPoP Proofs in Go
When exchanging an authorization code at the Singpass token endpoint, the Go service must sign both a short-lived `client_assertion` JWT (using the relying party's registered ECDSA P-256 private key in AWS KMS / Cloud KMS) and a sender-constrained `DPoP` HTTP header binding the token to the exact HTTP method (`htm`) and target URI (`htu`):
package singpass
import (
"crypto/ecdsa"
"time"
"github.com/golang-jwt/jwt/v5"
"github.com/google/uuid"
)
func BuildPrivateKeyJWTAssertion(
clientID string,
tokenEndpointAudience string,
keyID string,
privKey *ecdsa.PrivateKey,
) (string, error) {
now := time.Now().UTC()
claims := jwt.RegisteredClaims{
Issuer: clientID,
Subject: clientID,
Audience: jwt.ClaimStrings{tokenEndpointAudience},
IssuedAt: jwt.NewNumericDate(now),
ExpiresAt: jwt.NewNumericDate(now.Add(2 * time.Minute)),
ID: uuid.NewString(),
}
token := jwt.NewWithClaims(jwt.SigningMethodES256, claims)
token.Header["kid"] = keyID
token.Header["typ"] = "JWT"
return token.SignedString(privKey)
}
2. Decrypting Nested JWE (`ECDH-ES+A256KW`) & Verifying Inner JWS Signatures
MyInfo person responses and Singpass ID tokens arrive as a Compact JWE (`5` base64url segments) wrapping an inner signed JWS (`3` segments). Our Go gateway decrypts the outer JWE layer using our private encryption key, fetches Singpass's rotating `.well-known/keys` JWKS to verify the inner ES256 JWS signature, and validates the `nonce` and `at_hash` claims—integrating with our Enterprise OAuth 2.0 & OIDC Identity Architecture and Hexagonal Go Microservices.
Need a Backend Engineer to implement FAPI 2.0 OIDC, Singpass/MyInfo, or cryptographic identity gateways in Go? Book a 1-Day Engineering Sprint.