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

Firebase tools rejects any refreshed token after one week which deem it revoked #1026

Open
m-elgamal opened this issue Mar 30, 2024 · 1 comment

Comments

@m-elgamal
Copy link

m-elgamal commented Mar 30, 2024

Describe the bug
Emulator always revokes tokens that are older than one week

To Reproduce
When using firebase emulator, after a week of authentication, token passes the expired token check but never pass the token revoked check

Facing this issue for few month now for a project i'm working on. Had to debug through the firebase tools as follows:
in node_modules/firebase-admin/lib/base-auth.js
in the verifyDecodedJWTNotRevokedOrDisabled function:

decodedIdToken = {
    "name": "",
    "picture": "",
    "roles": [
        "admin"
    ],
    "email": "*****************",
    "email_verified": false,
    "auth_time": 1704074185,   <<<<<<-------------------------------
    "user_id": "hcHenhueMtmiDDa8MUXMg30jXIj0",
    "firebase": {
        "identities": {
            "email": [
                "****************"
            ]
        },
        "sign_in_provider": "password"
    },
    "iat": 1711809021,
    "exp": 1711812621,
    "aud": "************",
    "iss": "https://securetoken.google.com/togonowreact",
    "sub": "hcHenhueMtmiDDa8MUXMg30jXIj0",
    "uid": "hcHenhueMtmiDDa8MUXMg30jXIj0"
}

Emulator will always throw token revoked error if the login is over a week even though the token has been refreshed

const authTimeUtc = decodedIdToken.auth_time * 1000;
// Get user tokens valid after time in milliseconds UTC.
const validSinceUtc = new Date(user.tokensValidAfterTime).getTime();
// Check if authentication time is older than valid since time.
if (authTimeUtc < validSinceUtc) {
throw new error_1.FirebaseAuthError(revocationErrorInfo);
}

node_modules/firebase-admin/lib/base-auth.js:
Screenshots
image

As of now, the decodedidToekn resolved to the following PST time:

authTimeUtc: 1704074185000
which resolves to: Sunday, December 31, 2023 5:56:25 PM


validSinceUtc: new Date(user.tokensValidAfterTime).getTime()
1711179389000
which resolves to: Saturday, March 23, 2024 12:36:29 AM

Which always results true on the following if statement

                if (authTimeUtc < validSinceUtc) {
                    throw new error_1.FirebaseAuthError(revocationErrorInfo);
                }

@m-elgamal m-elgamal changed the title Firebase tools rejects any refreshed token after one week as revoked Firebase tools rejects any refreshed token after one week which deem it revoked Apr 3, 2024
@m-elgamal
Copy link
Author

Bump!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant