Skip to content

Commit

Permalink
Fix Charset to UTF-8 used by token value hash function (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
federicaagostini authored Jan 24, 2024
1 parent 29ec962 commit 1924382
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion openid-connect-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>openid-connect-parent</artifactId>
<groupId>org.mitre</groupId>
<version>1.3.6.cnaf-20231129</version>
<version>1.3.6.cnaf-20240119</version>
<relativePath>..</relativePath>
</parent>
<artifactId>openid-connect-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion openid-connect-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>openid-connect-parent</artifactId>
<groupId>org.mitre</groupId>
<version>1.3.6.cnaf-20231129</version>
<version>1.3.6.cnaf-20240119</version>
<relativePath>..</relativePath>
</parent>
<artifactId>openid-connect-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
package org.mitre.oauth2.model;

import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -349,9 +350,8 @@ public void setIdToken(JWT idToken) {

public void hashMe() {
if (jwtValue != null) {
this.tokenValueHash = Hashing.sha256()
.hashUnencodedChars(jwtValue.serialize())
.toString();
this.tokenValueHash =
Hashing.sha256().hashString(jwtValue.serialize(), StandardCharsets.UTF_8).toString();
}
}
}
2 changes: 1 addition & 1 deletion openid-connect-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.mitre</groupId>
<artifactId>openid-connect-parent</artifactId>
<version>1.3.6.cnaf-20231129</version>
<version>1.3.6.cnaf-20240119</version>
<relativePath>..</relativePath>
</parent>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ public Set<OAuth2RefreshTokenEntity> getAllRefreshTokens() {
}

@Override
public OAuth2AccessTokenEntity getAccessTokenByValue(
String accessTokenValue) {
String atHashed = Hashing.sha256()
.hashUnencodedChars(accessTokenValue)
.toString();
public OAuth2AccessTokenEntity getAccessTokenByValue(String accessTokenValue) {
String atHashed =
Hashing.sha256().hashString(accessTokenValue, StandardCharsets.UTF_8).toString();
TypedQuery<OAuth2AccessTokenEntity> query = manager.createNamedQuery(
OAuth2AccessTokenEntity.QUERY_BY_TOKEN_VALUE_HASH,
OAuth2AccessTokenEntity.class);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.mitre</groupId>
<artifactId>openid-connect-parent</artifactId>
<version>1.3.6.cnaf-20231129</version>
<version>1.3.6.cnaf-20240119</version>
<name>MITREid Connect</name>
<packaging>pom</packaging>
<parent>
Expand Down

0 comments on commit 1924382

Please sign in to comment.