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

[SDK-3816] Update docs for verification thread-safety #605

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/src/main/java/com/auth0/jwt/JWTVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ static Verification init(Algorithm algorithm) throws IllegalArgumentException {
}

/**
* {@link Verification} implementation that accepts all the expected Claim values for verification.
* {@link Verification} implementation that accepts all the expected Claim values for verification, and
* builds a {@link com.auth0.jwt.interfaces.JWTVerifier} used to verify a JWT's signature and expected claims.
*
* Note that this class is <strong>not</strong> thread-safe. Calling {@link #build()} returns an instance of
* {@link com.auth0.jwt.interfaces.JWTVerifier} which can be reused.
*/
public static class BaseVerification implements Verification {
private final Algorithm algorithm;
Expand Down
14 changes: 13 additions & 1 deletion lib/src/main/java/com/auth0/jwt/interfaces/JWTVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@


/**
* Used to verify the JWT for its signature and claims.
* Used to verify the JWT for its signature and claims. Implementations must be thread-safe. Instances are created
* using {@link Verification}.
*
* <pre>
* try {
* JWTVerifier verifier = JWTVerifier.init(Algorithm.RSA256(publicKey, privateKey)
* .withIssuer("auth0")
* .build();
* DecodedJWT jwt = verifier.verify("token");
* } catch (JWTVerificationException e) {
* // invalid signature or claims
* }
* </pre>
*/
public interface JWTVerifier {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import java.util.function.BiPredicate;

/**
* Constructs and holds the checks required for a JWT to be considered valid.
* Constructs and holds the checks required for a JWT to be considered valid. Note that implementations are
* <strong>not</strong> thread-safe. Once built by calling {@link #build()}, the resulting
* {@link com.auth0.jwt.interfaces.JWTVerifier} is thread-safe.
*/
public interface Verification {

Expand Down