Skip to content

Commit 89d897c

Browse files
authored
Merge pull request #141 from fjobeir/develop
Allow multiple iss domains
2 parents 413c09d + 4412c3f commit 89d897c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Auth.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,21 @@ public static function validate_token( $token = null, $refresh = false ) {
587587
return $token;
588588
}
589589

590+
/**
591+
* Allow multiple domains to be used as token iss value
592+
* This is useful if you want to make your token valid over several domains
593+
* Default value is the current site url
594+
* Used along with the 'graphql_jwt_auth_token_before_sign' filter
595+
*/
596+
597+
$allowed_domains = array(get_bloginfo('url'));
598+
$allowed_domains = apply_filters('graphql_jwt_auth_iss_allowed_domains', $allowed_domains);
599+
590600
/**
591601
* The Token is decoded now validate the iss
592602
*/
593-
if ( ! isset( $token->iss ) || get_bloginfo( 'url' ) !== $token->iss ) {
603+
604+
if ( ! isset( $token->iss ) || !in_array($token->iss, $allowed_domains) ) {
594605
// See https://github.com/wp-graphql/wp-graphql-jwt-authentication/issues/111
595606
self::set_status(401);
596607
return new \WP_Error( 'invalid-jwt', __( 'The iss do not match with this server', 'wp-graphql-jwt-authentication' ) );

0 commit comments

Comments
 (0)