Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional claims to token #66

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,21 @@ private String issueIdToken(String audience, String nonce, IdTokenJWS federatedI
// complete list of scopes and corresponding claims:
// https://fachportal.gematik.de/fachportal-import/files/gemSpec_IDP_Sek_V2.0.1.pdf
// Specification 4.2.4 - A_22989 -

claimsBuilder.claim("birthdate", federatedIdToken.body().telematikBirthdate());
claimsBuilder.claim("urn:telematik:claims:alter", federatedIdToken.body().telematikAlter());
claimsBuilder.claim(
"urn:telematik:claims:display_name", federatedIdToken.body().telematikDisplayName());
claimsBuilder.claim(
"urn:telematik:claims:given_name", federatedIdToken.body().telematikGivenName());
claimsBuilder.claim(
"urn:telematik:claims:geschlecht", federatedIdToken.body().telematikGeschlecht());
claimsBuilder.claim("urn:telematik:claims:email", federatedIdToken.body().telematikEmail());
claimsBuilder.claim(
"urn:telematik:claims:profession", federatedIdToken.body().telematikProfession());
claimsBuilder.claim("urn:telematik:claims:id", federatedIdToken.body().telematikKvnr());
claimsBuilder.claim(
"urn:telematik:claims:organization", federatedIdToken.body().telematikOrganization());

var claims = claimsBuilder.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ void redeem_twice() throws JOSEException {
new IdTokenJWS(
null,
new IdToken(
null, "tobias", null, 0, 0, 0, null, null, null, null, null, null, null, null));
null, "tobias", null, 0, 0, 0, null, null, null, null, null, null, null, null, null,
null, null, null, null));

var id = UUID.randomUUID().toString();
var code =
Expand Down Expand Up @@ -183,7 +184,8 @@ void redeem_idToken() throws JOSEException, ParseException {
new IdTokenJWS(
null,
new IdToken(
null, "tobias", null, 0, 0, 0, null, null, null, null, null, null, null, null));
null, "tobias", null, 0, 0, 0, null, null, null, null, null, null, null, null, null,
null, null, null, null));

var code =
new Code(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import org.junit.jupiter.api.Test;

class TokenEndpointTest {

private static final URI BASE_URI = URI.create("https://idp.example.com");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty of removing this unused field

private static final URI REDIRECT_URI = URI.create("https://myapp.example.com");

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ public record IdToken(
@JsonProperty("acr") String acr,
@JsonProperty("amr") String amr,
@JsonProperty("email") String email,
@JsonProperty("urn:telematik:claims:profession") String telematikProfession,

// The gemspec says that the claim is "birthdate", but
// all other claims are prefixed with "urn:telematik:claims:".
// I decided to implement to spec but we will likely need to adapt this.
@JsonProperty("birthdate") String telematikBirthdate,
@JsonProperty("urn:telematik:claims:alter") String telematikAlter,
@JsonProperty("urn:telematik:claims:display_name") String telematikDisplayName,
@JsonProperty("urn:telematik:claims:given_name") String telematikGivenName,
@JsonProperty("urn:telematik:claims:geschlecht") String telematikGeschlecht,
@JsonProperty("urn:telematik:claims:email") String telematikEmail,
@JsonProperty("urn:telematik:claims:profession") String telematikProfession,

// for insured person (IP) the immutable part of the Krankenversichertennummer (KVNR)
@JsonProperty("urn:telematik:claims:id") String telematikKvnr,
@JsonProperty("urn:telematik:claims:email") String telematikEmail) {}
@JsonProperty("urn:telematik:claims:organization") String telematikOrganization) {}
}