Skip to content

Commit

Permalink
Remove legacy modes
Browse files Browse the repository at this point in the history
Udap.org/TestTool has been updated and legacy modes no longer needed.
  • Loading branch information
JosephEShook committed May 6, 2024
1 parent 25b05fd commit 5c520d6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 73 deletions.
48 changes: 12 additions & 36 deletions Udap.Model/Access/AccessTokenRequestForAuthorizationCodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,13 @@ public AccessTokenRequestForAuthorizationCodeBuilder WithClaim(Claim claim)
}

/// <summary>
/// Legacy refers to the current udap.org/UDAPTestTool behavior as documented in
/// udap.org profiles. The HL7 Security IG has the following constraint to make it
/// more friendly with OIDC and SMART launch frameworks.
/// sub == iss == client_id
/// Where as the Legacy is the following behavior
/// sub == iis == SubAlt Name
/// Build an <see cref="UdapAuthorizationCodeTokenRequest"/>
/// </summary>
/// <param name="legacy"></param>
/// <param name="algorithm"></param>
/// <returns></returns>
public UdapAuthorizationCodeTokenRequest Build(
bool legacy = false,
string? algorithm = UdapConstants.SupportedAlgorithm.RS256)
public UdapAuthorizationCodeTokenRequest Build(string? algorithm = UdapConstants.SupportedAlgorithm.RS256)
{
var clientAssertion = BuildClientAssertion(algorithm, legacy);
var clientAssertion = BuildClientAssertion(algorithm);

return new UdapAuthorizationCodeTokenRequest()
{
Expand All @@ -99,34 +91,18 @@ public UdapAuthorizationCodeTokenRequest Build(
};
}

private string? BuildClientAssertion(string algorithm, bool legacy = false)
private string? BuildClientAssertion(string algorithm)
{
JwtPayLoadExtension jwtPayload;

if (legacy)
{
//udap.org profile
jwtPayload = new JwtPayLoadExtension(
_certificate.GetNameInfo(X509NameType.UrlName,
false), //TODO:: Let user pick the subject alt name. Create will need extra param.
_tokenEndpoint, //The FHIR Authorization Server's token endpoint URL
_claims,
_now,
_now.AddMinutes(5)
);
}

else
{
//HL7 FHIR IG profile
jwtPayload = new JwtPayLoadExtension(
_clientId,
_tokenEndpoint, //The FHIR Authorization Server's token endpoint URL
_claims,
_now,
_now.AddMinutes(5)
);
}
//HL7 FHIR IG profile
jwtPayload = new JwtPayLoadExtension(
_clientId,
_tokenEndpoint, //The FHIR Authorization Server's token endpoint URL
_claims,
_now,
_now.AddMinutes(5)
);

return SignedSoftwareStatementBuilder<JwtPayLoadExtension>
.Create(_certificate, jwtPayload)
Expand Down
50 changes: 13 additions & 37 deletions Udap.Model/Access/AccessTokenRequestForClientCredentialsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,13 @@ public AccessTokenRequestForClientCredentialsBuilder WithExtension(string key, B
}

/// <summary>
/// Legacy refers to the current udap.org/UDAPTestTool behavior as documented in
/// udap.org profiles. The HL7 Security IG has the following constraint to make it
/// more friendly with OIDC and SMART launch frameworks.
/// sub == iss == client_id
/// Where as the Legacy is the following behavior
/// sub == iis == SubAlt Name
/// Build an <see cref="UdapClientCredentialsTokenRequest"/>
/// </summary>
/// <param name="legacy"></param>
/// <param name="algorithm"></param>
/// <returns></returns>
public UdapClientCredentialsTokenRequest Build(
bool legacy = false,
string? algorithm = UdapConstants.SupportedAlgorithm.RS256)
public UdapClientCredentialsTokenRequest Build(string? algorithm = UdapConstants.SupportedAlgorithm.RS256)
{
var clientAssertion = BuildClientAssertion(algorithm, legacy);
var clientAssertion = BuildClientAssertion(algorithm);

return new UdapClientCredentialsTokenRequest
{
Expand All @@ -122,34 +114,18 @@ public UdapClientCredentialsTokenRequest Build(
}


private string BuildClientAssertion(string algorithm, bool legacy = false)
private string BuildClientAssertion(string algorithm)
{
JwtPayLoadExtension jwtPayload;

if (legacy)
{
//udap.org profile
jwtPayload = new JwtPayLoadExtension(
_certificate.GetNameInfo(X509NameType.UrlName,
false), //TODO:: Let user pick the subject alt name. Create will need extra param.
_tokenEndoint, //The FHIR Authorization Server's token endpoint URL
_claims,
_now,
_now.AddMinutes(5)
);
}

else
{
//HL7 FHIR IG profile
jwtPayload = new JwtPayLoadExtension(
_clientId, //TODO:: Let user pick the subject alt name. Create will need extra param.
_tokenEndoint, //The FHIR Authorization Server's token endpoint URL
_claims,
_now,
_now.AddMinutes(5)
);
}

//HL7 FHIR IG profile
jwtPayload = new JwtPayLoadExtension(
_clientId, //TODO:: Let user pick the subject alt name. Create will need extra param.
_tokenEndoint, //The FHIR Authorization Server's token endpoint URL
_claims,
_now,
_now.AddMinutes(5)
);

if (_extensions != null)
{
Expand Down

0 comments on commit 5c520d6

Please sign in to comment.