File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff 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 ' ) );
You can’t perform that action at this time.
0 commit comments