- JWT Authentication for WP REST API 플러그인 설치
https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/
- htaccess 파일 아래와 같이 수정
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# END WordPress
- wp-config.php 파일에 아래 추가
시크릿키는 여기서 https://api.wordpress.org/secret-key/1.1/salt/
define('JWT_AUTH_SECRET_KEY', '시크릿키');
- \htdocs\wp-content\plugins\jwt-authentication-for-wp-rest-api\public\class-jwt-auth-public.php 파일 수정
validate_token 함수에 아래 로직 적절히 추가
if (!$auth) {
$allHeaders = getallheaders();
$auth = isset($allHeaders['Authorization']) ? $allHeaders['Authorization'] : false;
}