Skip to content

Commit

Permalink
docs: Explains about the behavior of 'verify' on expired tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
fschuindt committed May 11, 2023
1 parent 26a3f38 commit fbf1c36
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Explains on `README.md` about the behavior of `verify` on expired tokens. [Details here](https://github.com/fschuindt/firebase_id_token/issues/29).

### Changed
- It won't default to `Redis.new` anymore. You must now provide Redis details during configuration. [Details here](https://github.com/fschuindt/firebase_id_token/issues/30).

Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,23 @@ FirebaseIdToken::Signature.verify('aaaaaa')
=> nil
```

**WARNING:** If you try to verify a signature without any certificates in Redis database it will raise a `FirebaseIdToken::Exceptions::NoCertificatesError`.
#### WARNING!

##### Expired tokens can point to long gone certificates

Notice that often when the token have expired, the Firebase certificate can be already missing from the Firebase servers. In these cases, `verify` will return `nil`.

If you want to take specific actions, here's a solution suggested by the user [cfanpnk](https://github.com/fschuindt/firebase_id_token/issues/29#issuecomment-751137511):

1. Use `verify!` to raise an exception.
2. Rescue `FirebaseIdToken::Exceptions::CertificateNotFound` and return `401`.
3. The client app will refresh the token if expired.

More details [here](https://github.com/fschuindt/firebase_id_token/issues/29).

##### Trying to verify tokens without downloaded certificates will raise an error

If you try to verify a signature without any certificates in Redis database it will raise a `FirebaseIdToken::Exceptions::NoCertificatesError`.

#### Payload Structure

Expand Down

0 comments on commit fbf1c36

Please sign in to comment.