Skip to content

Commit 5e1aea3

Browse files
committed
Address PR feedback
1 parent 1a3009b commit 5e1aea3

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

src/main/java/com/google/firebase/appcheck/AppCheckErrorCode.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,5 @@ public enum AppCheckErrorCode {
2929
/**
3030
* Internal server error.
3131
*/
32-
INTERNAL,
33-
34-
/**
35-
* User is not authenticated.
36-
*/
37-
UNAUTHENTICATED,
32+
INTERNAL
3833
}

src/main/java/com/google/firebase/appcheck/AppCheckTokenVerifier.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private AppCheckTokenVerifier(Builder builder) {
6868
DecodedAppCheckToken verifyToken(String token) throws FirebaseAppCheckException {
6969
SignedJWT signedJWT;
7070
JWTClaimsSet claimsSet;
71-
String scopedProjectId = String.format("projects/%s", projectId);
71+
String projectName = String.format("projects/%s", projectId);
7272
String projectIdMatchMessage = " Make sure the App Check token comes from the same "
7373
+ "Firebase project as the service account used to authenticate this SDK.";
7474

@@ -88,10 +88,10 @@ DecodedAppCheckToken verifyToken(String token) throws FirebaseAppCheckException
8888
} else if (!signedJWT.getHeader().getType().getType().equals("JWT")) {
8989
errorMessage = String.format("The provided App Check token has invalid type header."
9090
+ "Expected %s but got %s", "JWT", signedJWT.getHeader().getType().getType());
91-
} else if (!claimsSet.getAudience().contains(scopedProjectId)) {
91+
} else if (!claimsSet.getAudience().contains(projectName)) {
9292
errorMessage = String.format("The provided App Check token has incorrect 'aud' (audience) "
9393
+ "claim. Expected %s but got %s. %s",
94-
scopedProjectId, claimsSet.getAudience().toString(), projectIdMatchMessage);
94+
projectName, claimsSet.getAudience().toString(), projectIdMatchMessage);
9595
} else if (!claimsSet.getIssuer().startsWith(APP_CHECK_ISSUER)) {
9696
errorMessage = "invalid iss";
9797
} else if (claimsSet.getSubject().isEmpty()) {

src/main/java/com/google/firebase/appcheck/DecodedAppCheckToken.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ public String getAudience() {
5252
}
5353

5454
/** Returns the Expiration Time for this token. */
55-
public String getExpirationTime() {
56-
return (String) claims.get("exp");
55+
public Long getExpirationTime() {
56+
return (Long) claims.get("exp");
5757
}
5858

5959
/** Returns the Issued At for this token. */
60-
public String getIssuedAt() {
61-
return (String) claims.get("iat");
60+
public Long getIssuedAt() {
61+
return (Long) claims.get("iat");
6262
}
6363

6464
/** Returns a map of all the claims on this token. */

src/main/java/com/google/firebase/auth/FirebaseToken.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public final class FirebaseToken {
3737
this.claims = ImmutableMap.copyOf(claims);
3838
}
3939

40-
/** Returns the Uid for the this token. */
40+
/** Returns the Uid for this token. */
4141
public String getUid() {
4242
return (String) claims.get("sub");
4343
}
4444

45-
/** Returns the tenant ID for the this token. */
45+
/** Returns the tenant ID for this token. */
4646
public String getTenantId() {
4747
Map<String, Object> firebase = (Map<String, Object>) claims.get("firebase");
4848
if (firebase == null) {
@@ -51,7 +51,7 @@ public String getTenantId() {
5151
return (String) firebase.get("tenant");
5252
}
5353

54-
/** Returns the Issuer for the this token. */
54+
/** Returns the Issuer for this token. */
5555
public String getIssuer() {
5656
return (String) claims.get("iss");
5757
}
@@ -81,7 +81,7 @@ public boolean isEmailVerified() {
8181
return emailVerified != null && (Boolean) emailVerified;
8282
}
8383

84-
/** Returns a map of all of the claims on this token. */
84+
/** Returns a map of all the claims on this token. */
8585
public Map<String, Object> getClaims() {
8686
return this.claims;
8787
}

0 commit comments

Comments
 (0)