Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Allow multiple iss domains
Allow multiple domains to be used as token iss value and make your token valid over several domains
  • Loading branch information
fjobeir committed Oct 6, 2021
commit 3bf4572aefb083ec99b86aed739116bdec0e6b8b
12 changes: 11 additions & 1 deletion src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,20 @@ public static function validate_token( $token = null, $refresh = false ) {
return $token;
}

/**
* Allow multiple domains to be used as token iss value
* This is useful if you want to make your token valid over several domains
* Default value is the current site url
* Used along with the 'graphql_jwt_auth_token_before_sign' filter
*/

$allowed_domains = array(get_bloginfo('url'));
$allowed_domains = apply_filters('graphql_jwt_auth_iss_allowed_domains', $allowed_domains);

/**
* The Token is decoded now validate the iss
*/
if ( ! isset( $token->iss ) || get_bloginfo( 'url' ) !== $token->iss ) {
if ( ! isset( $token->iss ) || !in_array($token->iss, $allowed_domains) ) {
return new \WP_Error( 'invalid-jwt', __( 'The iss do not match with this server', 'wp-graphql-jwt-authentication' ) );
}

Expand Down