Changeset 2811049
- Timestamp:
- 11/03/2022 01:08:13 PM (3 years ago)
- Location:
- wp-rest-api-authentication
- Files:
-
- 167 added
- 11 edited
-
tags/2.4.1 (added)
-
tags/2.4.1/README.txt (added)
-
tags/2.4.1/admin (added)
-
tags/2.4.1/admin/class-miniorange-api-authentication-admin.php (added)
-
tags/2.4.1/admin/class-miniorange-api-authentication-customer.php (added)
-
tags/2.4.1/admin/css (added)
-
tags/2.4.1/admin/css/bootstrap (added)
-
tags/2.4.1/admin/css/bootstrap/bootstrap.min.css (added)
-
tags/2.4.1/admin/css/materialdesignicons.min.css (added)
-
tags/2.4.1/admin/css/miniorange-api-authentication-admin.css (added)
-
tags/2.4.1/admin/css/miniorange-api-authentication-license.css (added)
-
tags/2.4.1/admin/css/tick.png (added)
-
tags/2.4.1/admin/images (added)
-
tags/2.4.1/admin/images/100.jpg (added)
-
tags/2.4.1/admin/images/LearnDash-Logo.png (added)
-
tags/2.4.1/admin/images/account.png (added)
-
tags/2.4.1/admin/images/api-key.png (added)
-
tags/2.4.1/admin/images/api.png (added)
-
tags/2.4.1/admin/images/api_integrate.png (added)
-
tags/2.4.1/admin/images/apikey-postman.png (added)
-
tags/2.4.1/admin/images/apikey.png (added)
-
tags/2.4.1/admin/images/authentication.png (added)
-
tags/2.4.1/admin/images/basic-auth-postman.png (added)
-
tags/2.4.1/admin/images/basic-auth.png (added)
-
tags/2.4.1/admin/images/basic-key.png (added)
-
tags/2.4.1/admin/images/buddypress.png (added)
-
tags/2.4.1/admin/images/cancel.png (added)
-
tags/2.4.1/admin/images/carpentry.png (added)
-
tags/2.4.1/admin/images/cocart-icon.PNG (added)
-
tags/2.4.1/admin/images/configuration.png (added)
-
tags/2.4.1/admin/images/controller.png (added)
-
tags/2.4.1/admin/images/document.png (added)
-
tags/2.4.1/admin/images/edit.png (added)
-
tags/2.4.1/admin/images/equalizer.png (added)
-
tags/2.4.1/admin/images/faq.png (added)
-
tags/2.4.1/admin/images/firebase.png (added)
-
tags/2.4.1/admin/images/flags16.png (added)
-
tags/2.4.1/admin/images/forgot.png (added)
-
tags/2.4.1/admin/images/gatsby.png (added)
-
tags/2.4.1/admin/images/gravityform.jpg (added)
-
tags/2.4.1/admin/images/guarantee.png (added)
-
tags/2.4.1/admin/images/heading.png (added)
-
tags/2.4.1/admin/images/hourglass.png (added)
-
tags/2.4.1/admin/images/jwt-postman.png (added)
-
tags/2.4.1/admin/images/jwt.png (added)
-
tags/2.4.1/admin/images/jwt_authentication.png (added)
-
tags/2.4.1/admin/images/key.png (added)
-
tags/2.4.1/admin/images/know-how.png (added)
-
tags/2.4.1/admin/images/learndash.png (added)
-
tags/2.4.1/admin/images/less.png (added)
-
tags/2.4.1/admin/images/login.png (added)
-
tags/2.4.1/admin/images/logo.png (added)
-
tags/2.4.1/admin/images/mail.png (added)
-
tags/2.4.1/admin/images/miniOrange-full-logo.png (added)
-
tags/2.4.1/admin/images/miniorange-eivJzZgs.png (added)
-
tags/2.4.1/admin/images/miniorange-logo.png (added)
-
tags/2.4.1/admin/images/miniorange.png (added)
-
tags/2.4.1/admin/images/mologo.png (added)
-
tags/2.4.1/admin/images/more.png (added)
-
tags/2.4.1/admin/images/mostpopular.png (added)
-
tags/2.4.1/admin/images/mostsecure.png (added)
-
tags/2.4.1/admin/images/oauth.png (added)
-
tags/2.4.1/admin/images/oauth_2.png (added)
-
tags/2.4.1/admin/images/oidc.png (added)
-
tags/2.4.1/admin/images/openid-connect.png (added)
-
tags/2.4.1/admin/images/postman.png (added)
-
tags/2.4.1/admin/images/premium.png (added)
-
tags/2.4.1/admin/images/questions.png (added)
-
tags/2.4.1/admin/images/remove.png (added)
-
tags/2.4.1/admin/images/safe.png (added)
-
tags/2.4.1/admin/images/saml.png (added)
-
tags/2.4.1/admin/images/sands-of-time.png (added)
-
tags/2.4.1/admin/images/secure.png (added)
-
tags/2.4.1/admin/images/select-all.png (added)
-
tags/2.4.1/admin/images/setting.png (added)
-
tags/2.4.1/admin/images/settings.png (added)
-
tags/2.4.1/admin/images/shield.png (added)
-
tags/2.4.1/admin/images/speed-limit-100.png (added)
-
tags/2.4.1/admin/images/statistics.png (added)
-
tags/2.4.1/admin/images/success.png (added)
-
tags/2.4.1/admin/images/third_party.png (added)
-
tags/2.4.1/admin/images/thirdparty.png (added)
-
tags/2.4.1/admin/images/tick.png (added)
-
tags/2.4.1/admin/images/trial.png (added)
-
tags/2.4.1/admin/images/trouble_2.png (added)
-
tags/2.4.1/admin/images/universal-key.png (added)
-
tags/2.4.1/admin/images/user-authentication.png (added)
-
tags/2.4.1/admin/images/user-based-login.png (added)
-
tags/2.4.1/admin/images/user-guide.png (added)
-
tags/2.4.1/admin/images/user.png (added)
-
tags/2.4.1/admin/images/warning.png (added)
-
tags/2.4.1/admin/images/woocommerce-circle.png (added)
-
tags/2.4.1/admin/images/woocommerce_third_party_intg.png (added)
-
tags/2.4.1/admin/images/wordpress-logo.png (added)
-
tags/2.4.1/admin/images/write.png (added)
-
tags/2.4.1/admin/images/youtube.png (added)
-
tags/2.4.1/admin/index.php (added)
-
tags/2.4.1/admin/js (added)
-
tags/2.4.1/admin/js/phone.js (added)
-
tags/2.4.1/admin/partials (added)
-
tags/2.4.1/admin/partials/account (added)
-
tags/2.4.1/admin/partials/account/class-mo-api-authentication-account.php (added)
-
tags/2.4.1/admin/partials/account/login (added)
-
tags/2.4.1/admin/partials/account/login/register.php (added)
-
tags/2.4.1/admin/partials/account/login/verify-password.php (added)
-
tags/2.4.1/admin/partials/advanced (added)
-
tags/2.4.1/admin/partials/advanced/class-mo-api-authentication-advancedsettings.php (added)
-
tags/2.4.1/admin/partials/advanced/class-mo-api-authentication-protectedrestapis.php (added)
-
tags/2.4.1/admin/partials/class-mo-api-authentication-admin-menu.php (added)
-
tags/2.4.1/admin/partials/config (added)
-
tags/2.4.1/admin/partials/config/class-mo-api-authentication-config.php (added)
-
tags/2.4.1/admin/partials/config/images (added)
-
tags/2.4.1/admin/partials/config/images/trouble_2.png (added)
-
tags/2.4.1/admin/partials/config/output (added)
-
tags/2.4.1/admin/partials/config/output/class-mo-api-authentication-basic-oauth-config.php (added)
-
tags/2.4.1/admin/partials/config/output/class-mo-api-authentication-jwt-auth-config.php (added)
-
tags/2.4.1/admin/partials/config/output/class-mo-api-authentication-oauth-client-config.php (added)
-
tags/2.4.1/admin/partials/config/output/class-mo-api-authentication-third-party-provider-config.php (added)
-
tags/2.4.1/admin/partials/config/output/class-mo-api-authentication-tokenapi-config.php (added)
-
tags/2.4.1/admin/partials/custom-api-integration (added)
-
tags/2.4.1/admin/partials/custom-api-integration/class-mo-api-authentication-custom-api-integration.php (added)
-
tags/2.4.1/admin/partials/custom-api-integration/class-mo-api-authentication-third-party-integrations.php (added)
-
tags/2.4.1/admin/partials/demo (added)
-
tags/2.4.1/admin/partials/demo/class-mo-api-authentication-demo.php (added)
-
tags/2.4.1/admin/partials/flow (added)
-
tags/2.4.1/admin/partials/flow/class-mo-api-authentication-basic-oauth.php (added)
-
tags/2.4.1/admin/partials/flow/class-mo-api-authentication-jwt-auth.php (added)
-
tags/2.4.1/admin/partials/flow/class-mo-api-authentication-tokenapi.php (added)
-
tags/2.4.1/admin/partials/flow/mo-api-authentication-flow.php (added)
-
tags/2.4.1/admin/partials/flow/mo-token-api-flow.php (added)
-
tags/2.4.1/admin/partials/license (added)
-
tags/2.4.1/admin/partials/license/class-mo-api-authentication-license.php (added)
-
tags/2.4.1/admin/partials/postman (added)
-
tags/2.4.1/admin/partials/postman/class-mo-api-authentication-postman.php (added)
-
tags/2.4.1/admin/partials/support (added)
-
tags/2.4.1/admin/partials/support/class-mo-api-authentication-faq.php (added)
-
tags/2.4.1/admin/partials/support/class-mo-api-authentication-feedback.php (added)
-
tags/2.4.1/admin/partials/support/class-mo-api-authentication-support.php (added)
-
tags/2.4.1/admin/partials/support/images (added)
-
tags/2.4.1/admin/partials/support/images/angry.png (added)
-
tags/2.4.1/admin/partials/support/images/happy.png (added)
-
tags/2.4.1/admin/partials/support/images/normal.png (added)
-
tags/2.4.1/admin/partials/support/images/sad.png (added)
-
tags/2.4.1/admin/partials/support/images/smile.png (added)
-
tags/2.4.1/css (added)
-
tags/2.4.1/css/font-awesome.css (added)
-
tags/2.4.1/css/phone.css (added)
-
tags/2.4.1/css/style_settings.css (added)
-
tags/2.4.1/fonts (added)
-
tags/2.4.1/fonts/FontAwesome.otf (added)
-
tags/2.4.1/fonts/fontawesome-webfont.eot (added)
-
tags/2.4.1/fonts/fontawesome-webfont.svg (added)
-
tags/2.4.1/fonts/fontawesome-webfont.ttf (added)
-
tags/2.4.1/fonts/fontawesome-webfont.woff (added)
-
tags/2.4.1/fonts/fontawesome-webfont.woff2 (added)
-
tags/2.4.1/includes (added)
-
tags/2.4.1/includes/class-miniorange-api-authentication-activator.php (added)
-
tags/2.4.1/includes/class-miniorange-api-authentication-deactivator.php (added)
-
tags/2.4.1/includes/class-miniorange-api-authentication-i18n.php (added)
-
tags/2.4.1/includes/class-miniorange-api-authentication-loader.php (added)
-
tags/2.4.1/includes/class-miniorange-api-authentication.php (added)
-
tags/2.4.1/includes/index.php (added)
-
tags/2.4.1/index.php (added)
-
tags/2.4.1/languages (added)
-
tags/2.4.1/languages/miniorange_api_authentication.pot (added)
-
tags/2.4.1/miniorange-api-authentication.php (added)
-
tags/2.4.1/uninstall.php (added)
-
trunk/README.txt (modified) (12 diffs)
-
trunk/admin/class-miniorange-api-authentication-admin.php (modified) (3 diffs)
-
trunk/admin/css/miniorange-api-authentication-admin.css (modified) (1 diff)
-
trunk/admin/partials/advanced/class-mo-api-authentication-protectedrestapis.php (modified) (1 diff)
-
trunk/admin/partials/config/output/class-mo-api-authentication-basic-oauth-config.php (modified) (7 diffs)
-
trunk/admin/partials/config/output/class-mo-api-authentication-jwt-auth-config.php (modified) (10 diffs)
-
trunk/admin/partials/flow/class-mo-api-authentication-basic-oauth.php (modified) (1 diff)
-
trunk/admin/partials/flow/mo-api-authentication-flow.php (modified) (3 diffs)
-
trunk/admin/partials/flow/mo-token-api-flow.php (modified) (5 diffs)
-
trunk/includes/class-miniorange-api-authentication.php (modified) (1 diff)
-
trunk/miniorange-api-authentication.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-rest-api-authentication/trunk/README.txt
r2761360 r2811049 3 3 Tags: api, rest-api, jwt auth, basic auth, jwt, REST, secure api, token, endpoints, json web token, oauth, api key auth 4 4 Requires at least: 3.0.1 5 Tested up to: 6. 06 Stable tag: 2.4. 05 Tested up to: 6.1 6 Stable tag: 2.4.1 7 7 Requires PHP: 5.6 8 8 License: MIT/Expat … … 13 13 14 14 == Description == 15 **Wordpress REST APIs** by default are **loose endpoints** through which a hacker can control your site remotely. You don’t want hackers to give access to your WordPress Login and Wordpress Register or any other endpoints. With our **[WordPress REST API Authentication plugin](https://plugins.miniorange.com/wordpress-rest-api-authentication)**, we promise to have the secure api from unauthorized users and **protects WP REST API endpoints** from public access using [API Key Authentication](https://plugins.miniorange.com/rest-api-key-authentication-method) or [JWT Authentication](https://plugins.miniorange.com/wordpress-rest-api-jwt-authentication-method) or [Basic Authentication](https://plugins.miniorange.com/wordpress-rest-api-basic-authentication-method) or [OAuth 2.0 Authentication](https://plugins.miniorange.com/wordpress-rest-api-oauth-2-0-authentication-method) or third-party OAuth 2.0/OIDC/[Firebase](https://firebase.google.com/docs/auth/admin/create-custom-tokens) provider's token authentication methods. Our plugin is made in a way to make sure that we always have a secure api connection so that data isn’t compromised. JWT Authentication is an industry -approved method to secure communication between 2 parties and we also allow you to use that on your wordpress website.15 **Wordpress REST APIs** by default are **loose endpoints** through which a hacker can control your site remotely. You don’t want hackers to give access to your WordPress Login and Wordpress Register or any other endpoints. With our **[WordPress REST API Authentication plugin](https://plugins.miniorange.com/wordpress-rest-api-authentication)**, we promise to have the secure api from unauthorized users and **protects WP REST API endpoints** from public access using [API Key Authentication](https://plugins.miniorange.com/rest-api-key-authentication-method) or [JWT Authentication](https://plugins.miniorange.com/wordpress-rest-api-jwt-authentication-method) or [Basic Authentication](https://plugins.miniorange.com/wordpress-rest-api-basic-authentication-method) or [OAuth 2.0 Authentication](https://plugins.miniorange.com/wordpress-rest-api-oauth-2-0-authentication-method) or third-party OAuth 2.0/OIDC/[Firebase](https://firebase.google.com/docs/auth/admin/create-custom-tokens) provider's token authentication methods. Our plugin is made in a way to make sure that we always have a secure api connection so that data isn’t compromised. JWT Authentication is an industry approved method to secure communication between 2 parties and we also allow you to use that on your wordpress website. 16 16 It also allows you to access the WordPress REST APIs using the above-mentioned authentication methods from Android / iOS and desktop applications. 17 17 This plugin will make sure that only after the successful authentication, the user is allowed to access your site's resources which adds to our motivation towards secure api. REST API Authentication will make your **WordPress login endpoints secure from unauthorized access.** You can protect api with ease and in a highly secure way using this plugin. 18 18 This plugin also provides features for authentication of custom-developed REST endpoints and third-party plugin REST API endpoints like that of [Woocommerce](https://wordpress.org/plugins/woocommerce/), [Learndash](https://www.learndash.com/), [Buddypress](https://wordpress.org/plugins/buddypress/), [Gravity forms](https://www.gravityforms.com/), [Cocart](https://wordpress.org/plugins/cart-rest-api-for-woocommerce/) etc. 19 19 20 **_You can create the custom routes/REST endpoints in WordPress with another GUI -based plugin [Custom API for WordPress](https://wordpress.org/plugins/custom-api-for-wp/)_**.20 **_You can create the custom routes/REST endpoints in WordPress with another GUI based plugin [Custom API for WordPress](https://wordpress.org/plugins/custom-api-for-wp/)_**. 21 21 22 22 You will be able to securely login into the rest api using the following endpoint: … … 35 35 * _jwt token (JSON Web tokens) from other Identity Providers (OAuth/OIDC providers)Authenticate/Protect/Secure WordPress REST API endpoints with the access token ._ 36 36 * _Securely Login and register into Mobile or other client applications using REST APIs._ 37 * _Obtain **user -based JWT token** to use as an authentication source to login and register on other platforms._37 * _Obtain **user based JWT token** to use as an authentication source to login and register on other platforms._ 38 38 * _Authenticate Woocommerce REST API endpoints by bypassing WooCommerce consumers' credentials security and instead of using their authentication methods to control the data access and thus improving security and removing chances for exposing the WC credentials._ 39 39 * _**Authenticate/secure WordPress REST APIs** access using Firebase JWT token, any external JWT token, any OAuth 2.0/OpenID Connect(OIDC) provider access/id-token like Azure AD, Azure B2C, Okta, Keycloak, ADFS, AWS Cognito etc or that provided by Social login providers like Google, Facebook, Apple. 40 40 The plugin provides an interface for applications to interact with your WordPress REST API endpoints by sending and receiving data as JSON (JavaScript Object Notation) objects. Also, It provides a user-friendly user interface of the plugin to configure the methods and implement them very easily. You can easily secure api/protect your WordPress REST API endpoints with ease._ 41 * _**API Authentication based on HTTP method (GET/POST/PUT/DELETE)** - This feature provides the facility to choose which APIs need to be restricted and which specific HTTP methods. For example - If you want to allow users to access HTTP GET API of wp/v2/users endpoint to view only the users' list and are not able to use the HTTP POST, PUT, or DELETE to modify them via a REST API request._42 41 43 42 With our plugin, the user credentials are not stored as cookies but with every API call, user credentials or JWT (JSON Web tokens) or API key are passed so that we have secure api transactions. … … 64 63 * This plugin supports interaction with Gravity Forms from an external client application which can be your android/iOS application. WP REST API Authentication also allows WordPress users to create, read, update and delete forms, entries, and results over HTTP based on their roles. 65 64 == Learndash API == 66 * This plugin allows you to securely access Learndash user profiles, courses, groups & many more third -party APIs.65 * This plugin allows you to securely access Learndash user profiles, courses, groups & many more third party APIs. 67 66 == Custom Built REST API Endpoints == 68 67 * The plugin **supports authentication for your own built custom REST API routes/endpoints**. You can secure these API endpoints using the plugin’s highly secured authentication methods. 69 68 == External/Third-party plugin API endpoints integration in WordPress == 70 69 * These integrations can be used to fetch/update the data from the third-party side into the WordPress that can be used to display it on the WordPress site as well as this data can be processed further to use with any other plugin or WordPress events. 71 == Authentication for API access securely in Headless WordPress == 72 * Using this plugin, you can access your WordPress REST API endpoints securely on your Headless WordPress having the front end built via Angular, React, Node JS, Vue etc. 73 74 70 75 71 == FEATURES == 76 72 … … 131 127 132 128 = How to enable API access in WooCommerce? 133 You can enable API access in WooCommerce using our WP REST API Authentication plugin. Please reach out to us at api[email protected].129 You can enable API access in WooCommerce using our WP REST API Authentication plugin. Please reach out to us at oauth[email protected]. 134 130 135 131 = How does the REST API Authentication plugin work? = … … 142 138 To access the pages/posts stored in the draft, you need to append the ?status=draft to the page/post request. 143 139 For Example: 144 You need to use below URL format while sending a request to access different typesof posts140 You need to use below URL format while sending request to access different type of posts 145 141 1. Access draft posts only 146 142 https://<domain>/wp-json/wp/v2/posts?status=draft 147 2. Access all type sof posts143 2. Access all type of posts 148 144 https://<domain>/wp-json/wp/v2/posts?status=any 149 You just have to change the status(draft, pending, any, publish) as per your requirement. You do not have to pass thestatus parameter to access Published posts.145 You just have to change the status(draft, pending, any, publish) as per your requirement. You do not have to pass status parameter to access Published posts. 150 146 151 147 = How can I authenticate the REST APIs using this plugin? = … … 174 170 This plugin provides this HTTP POST endpoint `wp-json/api/v1/token` also called as WordPress login API endpoint in which you can pass the user's WordPress credentials and this endpoint will validate the user and returns you with the appropriate response. 175 171 The plugin also supports the authentication and authorization of WordPress users' register REST API. 176 177 = Does this plugin provides accessing API securely in headless WordPress? =178 Yes, using this plugin, you can authenticate the WordPress REST API requests made from the front end of the Headless WordPress (Headless WP) built using Angular JS, React JS, Node JS, Vue JS, Flutter etc.179 172 180 173 … … 191 184 == Changelog == 192 185 193 = 2.4. 0=194 * Password validation enhancement for JWT authentication195 * Minor UI fixes186 = 2.4.1 = 187 * WordPress 6.1 compatibility 188 * Added the endpoint to check the JWT token for JWT authentication method. 196 189 197 190 = 2.3.0 = … … 218 211 219 212 = 1.6.7 = 220 * Compatib ility with WordPress 5.9213 * Compatiblity with WordPress 5.9 221 214 222 215 = 1.6.6 = … … 224 217 225 218 = 1.6.5 = 226 * WordPress 5.8.2 compatib ility219 * WordPress 5.8.2 compatiblity 227 220 * UI Changes 228 221 … … 231 224 232 225 = 1.6.3 = 233 * Word Press 5.8.1 compatibility226 * WordsPress 5.8.1 compatability 234 227 * Readme Updates 235 228 236 229 = 1.6.2 = 237 * WordPress 5.8 compatib ility230 * WordPress 5.8 compatiblity 238 231 * Bug Fixes 239 232 * Usability Improvements … … 304 297 * Added UI Changes 305 298 * Updated plugin licensing 306 * Added new features299 * Added New features 307 300 * Added compatibility for WP 5.3 & PHP7.4 308 301 * Minor UI & feature fixes -
wp-rest-api-authentication/trunk/admin/class-miniorange-api-authentication-admin.php
r2761358 r2811049 232 232 self::convergence(); 233 233 } 234 235 236 public function mo_api_auth_initialize_api_flow() { 234 235 public function register_rest_routes(){ 236 register_rest_route('api/v1','token-validate',array('methods' => 'GET', 237 'callback'=> array( $this, 'mo_rest_JWT_validate_token' ), 238 'permission_callback' => '__return_true', 239 )); 240 register_rest_route('api/v1','token',array('methods' => 'POST', 241 'callback'=> array($this,'mo_rest_token_generation_callback'), 242 'permission_callback' => '__return_true' 243 )); 244 245 } 246 247 public function mo_rest_api() { 248 return apply_filters( 'jwt_auth_alg', 'HS256' ); 249 } 250 251 public function mo_rest_token_generation_callback($request_body){ 252 $json=$request_body->get_params(); 253 $json=array('username'=>$json['username'],'password'=>$json['password']); 254 mo_api_auth_token_endpoint_flow($json); 255 256 } 257 258 public function mo_api_auth_initialize_api_flow(){ 259 mo_api_auth_restrict_rest_api_for_invalid_users(); 260 } 261 262 public function mo_rest_JWT_validate_token( $return_response = true ) { 263 $headerkey = mo_api_auth_getallheaders(); 264 $headerkey = array_change_key_case($headerkey, CASE_UPPER); 265 $response = Mo_API_Authentication_JWT_Auth::mo_api_auth_is_valid_request($headerkey); 266 if($response === true) 267 { 268 $response= ["status"=> "TRUE", 269 "message"=> "VALID_TOKEN", 270 "code"=> "200"]; 271 272 } 273 if($response === false) 274 { 275 276 $response= ['status' => "error", 277 'error' => 'UNAUTHORIZED', 278 'code' => '401', 279 'error_description' => 'Incorrect JWT Format.']; 280 281 } 282 wp_send_json($response); 283 } 284 285 286 public function mo_api_auth_initialize_api_flow_old() { 237 287 238 288 if(!empty($_GET['mo_rest_api_test_config'])) { … … 250 300 251 301 else{ 252 253 if ( !mo_api_auth_user_has_capability() && (strpos(sanitize_text_field($_SERVER['REQUEST_URI']), 'moserver') === false) ) { 302 if ( !mo_api_auth_user_has_capability()) { 254 303 if(strpos(sanitize_text_field($_SERVER['REQUEST_URI']), '/api/v1/token') !== false && get_option( 'mo_api_authentication_selected_authentication_method' ) === 'jwt_auth' ) { 255 304 $json = file_get_contents('php://input'); 256 305 $json = json_decode( $json, true ); 257 306 if( json_last_error() !== JSON_ERROR_NONE ) { 258 $json = array_map( ' esc_attr', $_POST );307 $json = array_map( 'sanitize_text_field', $_POST ); 259 308 } 260 309 mo_api_auth_token_endpoint_flow($json); … … 266 315 } 267 316 268 269 function regenerate_token() {270 if (sanitize_text_field($_SERVER['REQUEST_METHOD']) === 'POST' && current_user_can('administrator') ) {271 $bearer_token = stripslashes( wp_generate_password( 32, false, false ) );272 update_option( 'mo_api_auth_bearer_token ', $bearer_token );273 echo esc_attr( $bearer_token );274 wp_die();275 }276 }277 278 function regenerate_client_credentials(){279 if (sanitize_text_field($_SERVER['REQUEST_METHOD']) === 'POST' && current_user_can('administrator') ) {280 mo_api_authentication_create_client();281 $response = [282 'client_id' => get_option( 'mo_api_auth_clientid' ),283 'client_secret' => get_option( 'mo_api_auth_clientsecret' )284 ];285 wp_send_json( $response, 200 );286 }287 }288 289 317 function save_temporary_data(){ 290 318 291 if (sanitize_text_field($_SERVER['REQUEST_METHOD']) === 'POST' && current_user_can('administrator') ) {319 if (sanitize_text_field($_SERVER['REQUEST_METHOD']) === 'POST' && current_user_can('administrator') && wp_verify_nonce($_SERVER['nonce'] , 'mo_rest_api_temporal_data_nonce' ) ) { 292 320 if(isset($_POST['auth_method']) && sanitize_text_field($_POST['auth_method']) == 'basic_auth'){ 293 321 -
wp-rest-api-authentication/trunk/admin/css/miniorange-api-authentication-admin.css
r2720707 r2811049 1108 1108 } 1109 1109 1110 1110 .mo_oauth_rest_trobleshoot{ 1111 width: 1.3em; 1112 height: 1.3em; 1113 display: block; 1114 margin-bottom:-20px; 1115 } 1111 1116 1112 1117 .mo_test_config_string { color: white; } -
wp-rest-api-authentication/trunk/admin/partials/advanced/class-mo-api-authentication-protectedrestapis.php
r2761358 r2811049 104 104 105 105 public static function checkRouteIsWPStandardOrNot( $route ) { 106 107 106 if (stripos($route, '/wp/v2') === false){ 108 107 return false; -
wp-rest-api-authentication/trunk/admin/partials/config/output/class-mo-api-authentication-basic-oauth-config.php
r2761358 r2811049 214 214 <tr> 215 215 <td> 216 <br><br><input type='button' onclick=" test_config_basic_auth();" value="Test Configuration" class="mo_test_config_button"></button>216 <br><br><input type='button' onclick="mo_rest_api_JWTtest_config_basic_auth();" value="Test Configuration" class="mo_test_config_button"></button> 217 217 </td> 218 218 </tr> … … 225 225 <h4 id='basic_auth_response_text' style='display:none;'><b> Response: </b></h4> 226 226 <pre id="json_basic_auth" class = 'mo_test_config_response'></pre> 227 <h4 id='basic_display_text' style='display:none;'><img class="mo_oauth_rest_trobleshoot" src="<?php echo esc_url(dirname( plugin_dir_url( __FILE__ ) ));?>/images/trouble_2.png"><b style="margin-left:25px;"> TroubleShoot </b></h4> 228 <pre style='padding: 15px 10px 15px 25px;' id="basic_display_troubleshoot" class='mo_test_config_response'> 229 </pre> 227 230 <br> 228 231 <br> … … 244 247 'auth_method' : 'basic_auth', 245 248 'algo' : 'base64', 246 'token_type' : localStorage.getItem('mo_api_basic_token_type') 249 'token_type' : localStorage.getItem('mo_api_basic_token_type'), 250 'nonce': '<?php echo wp_create_nonce( 'mo_rest_api_temporal_data_nonce' ); ?>' 247 251 }; 248 252 … … 296 300 } 297 301 298 function test_config_basic_auth() {302 function mo_rest_api_JWTtest_config_basic_auth() { 299 303 var username = document.getElementById("rest_basic_auth_username").value; 300 304 var password = document.getElementById("rest_basic_auth_password").value; … … 321 325 fetch(endpoint, requestOptions) 322 326 .then(response => response.text()) 323 .then(result => display_basic_auth_data(result))327 .then(result => mo_rest_api_display_basic_auth_data(result)) 324 328 .catch(error => console.log('error', error)); 325 329 } 326 330 327 function output_basic_auth(inp) {331 function mo_rest_api_output_basic_auth(inp) { 328 332 document.getElementById("json_basic_auth").innerHTML = inp; 329 333 } 330 334 331 function syntaxHighlight_basic_auth(json) {335 function mo_rest_api_syntaxHighlight_basic_auth(json) { 332 336 json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); 333 337 return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { … … 349 353 } 350 354 351 function display_basic_auth_data(result) {355 function mo_rest_api_display_basic_auth_data(result) { 352 356 // console.log(result); 353 357 var data = JSON.parse(result); 354 358 var json = JSON.stringify(data, undefined, 4); 355 output_basic_auth(syntaxHighlight_basic_auth(json));359 mo_rest_api_output_basic_auth(mo_rest_api_syntaxHighlight_basic_auth(json)); 356 360 document.getElementById("json_basic_auth").style.display = "block"; 357 361 document.getElementById("basic_auth_request_headers").style.display = "block"; … … 359 363 document.getElementById("basic_auth_response_text").style.display = "block"; 360 364 document.getElementById("basic_auth_response_text").scrollIntoView({behavior: 'smooth' }); 361 } 365 if(data.error) 366 mo_rest_api_troubleshootPrintBasic(data.error); 367 else 368 mo_rest_api_troubleshootHideBasic(); 369 } 370 function mo_rest_api_troubleshootHideBasic(){ 371 372 document.getElementById("basic_display_troubleshoot").style.display = "none"; 373 document.getElementById("basic_display_text").style.display = "none"; 374 } 375 function mo_rest_api_troubleshootPrintBasic(err){ 376 if(err === "INVALID_PASSWORD") 377 { 378 document.getElementById("basic_display_troubleshoot").innerHTML = `<ul style="list-style: inside;"><li>Check if username and password entered are correct.</li><li>If yes try password without special charachters.</li></ul>`; 379 document.getElementById("basic_display_troubleshoot").style.display = "block"; 380 document.getElementById("basic_display_text").style.display = "inline-block"; 381 382 } 383 else if(err === "INVALID_USERNAME") 384 { 385 document.getElementById("basic_display_troubleshoot").innerHTML = '<ul style="list-style: inside;"><li>Check if user with this username exists.</li><li>Check if username entered is correct.</li></ul>'; 386 document.getElementById("basic_display_troubleshoot").style.display = "block"; 387 document.getElementById("basic_display_text").style.display = "inline-block"; 388 389 } 390 else if(err === "INVALID_CLIENT_CREDENTIALS") 391 { 392 document.getElementById("basic_display_troubleshoot").innerHTML = 'INVALID_CLIENT_CREDENTIALS'; 393 document.getElementById("basic_display_troubleshoot").style.display = "block"; 394 document.getElementById("basic_display_text").style.display = "inline-block"; 395 396 } 397 else if(err === "MISSING_AUTHORIZATION_HEADER") 398 { 399 document.getElementById("basic_display_troubleshoot").innerHTML = 'MISSING_AUTHORIZATION_HEADER'; 400 document.getElementById("basic_display_troubleshoot").style.display = "block"; 401 document.getElementById("basic_display_text").style.display = "inline-block"; 402 403 } 404 else if(err === "INVALID_AUTHORIZATION_HEADER_TOKEN_TYPE") 405 { 406 document.getElementById("basic_display_troubleshoot").innerHTML = 'INVALID_AUTHORIZATION_HEADER_TOKEN_TYPE'; 407 document.getElementById("basic_display_troubleshoot").style.display = "block"; 408 document.getElementById("basic_display_text").style.display = "inline-block"; 409 410 } 411 else if(err === "INVALID_TOKEN_FORMAT") 412 { 413 document.getElementById("basic_display_troubleshoot").innerHTML = 'INVALID_TOKEN_FORMAT'; 414 document.getElementById("basic_display_troubleshoot").style.display = "block"; 415 document.getElementById("basic_display_text").style.display = "inline-block"; 416 417 } 418 419 420 } 362 421 363 422 </script> -
wp-rest-api-authentication/trunk/admin/partials/config/output/class-mo-api-authentication-jwt-auth-config.php
r2761358 r2811049 144 144 </tr> 145 145 <tr> 146 <td><input type='button' value="POST" class='mo_test_config_request_method'> <input type='text' id='rest_token_endpoint' value="<?php echo esc_ html(get_rest_url())."api/v1/token"; ?>" readonly class='mo_test_config_input'></td>147 </tr> 148 <tr> 149 <td> 150 <br><input type='button' onclick=" test_config('token');" value="Fetch Token" class="mo_test_config_button"></button>146 <td><input type='button' value="POST" class='mo_test_config_request_method'> <input type='text' id='rest_token_endpoint' value="<?php echo esc_url(get_rest_url()."api/v1/token"); ?>" readonly class='mo_test_config_input'></td> 147 </tr> 148 <tr> 149 <td> 150 <br><input type='button' onclick="mo_JWT_test_config('token');" value="Fetch Token" class="mo_test_config_button"></button> 151 151 </td> 152 152 </tr> … … 156 156 <pre id="json_jwt_token" class='mo_test_config_response'> 157 157 </pre> 158 <h4 id='jwt_token_troubleshoot_text' style='display:none;'><img class="mo_oauth_rest_trobleshoot" src="<?php echo esc_url(dirname( plugin_dir_url( __FILE__ ) ));?>/images/trouble_2.png"><b style="margin-left:25px;"> TroubleShoot </b></h4> 159 <pre style='padding: 15px 10px 15px 25px;' id="json_jwt_token_troubleshoot" class='mo_test_config_response'> 160 161 </pre> 162 163 <table width="80%"> 164 <tr> 165 <td> 166 <p style='color:#2a2ea9; font-size: 1.1em;'><b>[2] Check if token is valid: </b></p> 167 </td> 168 </tr> 169 <tr> 170 <td> 171 <p>Token:</p> 172 <input type="text" id='rest_token_value' size="28" placeholder="Enter JWT Token" class='mo_test_config_input'> 173 </td> 174 </tr> 175 <tr> 176 <td> 177 <p>Token Validation Endpoint: </p> 178 </td> 179 </tr> 180 <tr> 181 <td><input type='button' value="GET" class='mo_test_config_request_method'> <input type='text' id='rest_validate_endpoint' value="<?php echo esc_url(get_rest_url()."api/v1/token-validate"); ?>" readonly class='mo_test_config_input'></td> 182 </tr> 183 <tr> 184 <td> 185 <br><input type='button' onclick="mo_JWT_test_config('validate');" value="Check Token" class="mo_test_config_button"></button> 186 </td> 187 </tr> 188 </table> 189 <br> 190 <h4 id='jwt_token_validate_response_text' style='display:none;'><b> Response: </b></h4> 191 <pre id="json_jwt_token_validate" class='mo_test_config_response'> 192 </pre> 193 <h4 id='jwt_token_validate_text' style='display:none;'><img class="mo_oauth_rest_trobleshoot" src="<?php echo esc_url(dirname( plugin_dir_url( __FILE__ ) ));?>/images/trouble_2.png"><b style="margin-left:25px;"> TroubleShoot </b></h4> 194 <pre style='padding: 15px 10px 15px 25px;' id="json_jwt_token_validate_troubleshoot" class='mo_test_config_response'> 195 196 </pre> 197 198 158 199 <table> 159 200 <tr> 160 201 <td> 161 <p style='color: #2a2ea9; font-size: 1.1em;'><b>[ 2] Access the protected REST APIs by using the jwt_token obtained from above Step[1]: </b></p>202 <p style='color: #2a2ea9; font-size: 1.1em;'><b>[3] Access the protected REST APIs by using the jwt_token obtained from above Step[1]: </b></p> 162 203 </td> 163 204 </tr> … … 179 220 <tr> 180 221 <td> 181 <br><input type='button' onclick=" test_config('rest');" value="Test Configuration" class="mo_test_config_button" />222 <br><input type='button' onclick="mo_JWT_test_config('rest');" value="Test Configuration" class="mo_test_config_button" /> 182 223 </td> 183 224 </tr> … … 190 231 <h4 id='jwt_token_api_response_text' style='display:none;'><b>Response: </b></h4> 191 232 <pre id="json_jwt" class='mo_test_config_response'> 233 </pre> 234 <h4 id='data_display_text' style='display:none;'><img class="mo_oauth_rest_trobleshoot" src="<?php echo esc_url(dirname( plugin_dir_url( __FILE__ ) ));?>/images/trouble_2.png"><b style="margin-left:25px;"> TroubleShoot </b></h4> 235 <pre style='padding: 15px 10px 15px 25px;' id="data_display_troubleshoot" class='mo_test_config_response'> 236 192 237 </pre> 193 238 <!-- <div id="json_jwt" style='display:none;'> --> … … 203 248 var token_endpoint_obj = document.getElementById('rest_token_endpoint'); 204 249 token_endpoint_obj.style.width = ((token_endpoint_obj.value.length + 1) * 7) + 'px'; 250 var token_endpoint_obj = document.getElementById('rest_validate_endpoint'); 251 token_endpoint_obj.style.width = ((token_endpoint_obj.value.length + 1) * 7) + 'px'; 205 252 var token_endpoint_obj = document.getElementById('rest_endpoint_jwt_auth'); 206 253 token_endpoint_obj.style.width = ((token_endpoint_obj.value.length + 1) * 7) + 'px'; … … 227 274 228 275 229 function test_config(event) {276 function mo_JWT_test_config(event) { 230 277 if(event === 'token') { 231 278 var token_endpoint = document.getElementById("rest_token_endpoint").value; … … 247 294 }; 248 295 249 token_endpoint = token_endpoint + "?mo_rest_api_test_config=jwt_auth"296 250 297 251 298 fetch(token_endpoint, requestOptions) 252 299 .then(response => response.text()) 253 .then(result => display_jwt_data(result))300 .then(result => moJWTdisplay_jwt_data(result)) 254 301 .catch(error => console.log('error', error)); 255 302 } 256 else { 257 var token = document.getElementById("rest_jwt_token").value; 258 var endpoint = document.getElementById("rest_endpoint_jwt_auth").value; 303 else if(event === "validate"){ 304 var validate_endpoint = document.getElementById("rest_validate_endpoint").value; 305 var token_val = document.getElementById("rest_token_value").value; 306 307 259 308 260 309 var myHeaders = new Headers(); 261 262 myHeaders.append("Authorization", "Bearer "+token); 263 document.getElementById("jwt_request_headers_value").textContent = token; 310 myHeaders.append('Content-Type', 'application/json'); 311 myHeaders.append('Authorization','Bearer '+ token_val); 264 312 265 313 var requestOptions = { … … 268 316 redirect: 'follow' 269 317 }; 270 271 endpoint = endpoint + "?mo_rest_api_test_config=jwt_auth" 318 validate_endpoint=validate_endpoint+ "?mo_rest_api_test_config=jwt_auth"; 319 320 fetch(validate_endpoint, requestOptions) 321 .then(response => response.text()) 322 .then(result => moJWTdisplay_token_val_data(result)) 323 .catch(error => console.log('error', error)); 324 325 } 326 else { 327 var token = document.getElementById("rest_jwt_token").value; 328 var endpoint = document.getElementById("rest_endpoint_jwt_auth").value; 329 330 var myHeaders = new Headers(); 331 332 myHeaders.append("Authorization", "Bearer "+token); 333 document.getElementById("jwt_request_headers_value").textContent = token; 334 335 var requestOptions = { 336 method: 'GET', 337 headers: myHeaders, 338 redirect: 'follow' 339 }; 340 341 endpoint = endpoint + "?mo_rest_api_test_config=jwt_auth"; 272 342 273 343 fetch(endpoint, requestOptions) 274 344 .then(response => response.text()) 275 .then(result => display_data(result))345 .then(result => moJWTdisplay_data(result)) 276 346 .catch(error => console.log('error', error)); 277 347 } 278 348 } 279 349 280 function display_jwt_data(result) { 281 // console.log(result); 350 function moJWTdisplay_jwt_data(result) { 282 351 var data = JSON.parse(result); 283 352 var json = JSON.stringify(data, undefined, 4); 284 output(syntaxHighlight(json), 'token');353 moJWToutput(moJWTsyntaxHighlight(json), 'token'); 285 354 document.getElementById("json_jwt_token").style.display = "block"; 286 355 document.getElementById("jwt_token_response_text").style.display = "block"; 287 356 document.getElementById("jwt_token_response_text").scrollIntoView({behavior: 'smooth' }); 288 } 289 290 function output(inp, endpoint) { 357 if(data.error) 358 moJWTtroubleshootPrintJWT(data.error , 'token'); 359 else 360 moJWTtroubleshootHideJWT('token'); 361 } 362 function moJWTdisplay_token_val_data(result) { 363 var data = JSON.parse(result); 364 var json = JSON.stringify(data, undefined, 4); 365 moJWToutput(moJWTsyntaxHighlight(json), 'validate'); 366 document.getElementById("json_jwt_token_validate").style.display = "block"; 367 document.getElementById("jwt_token_validate_response_text").style.display = "block"; 368 document.getElementById("jwt_token_validate_response_text").scrollIntoView({behavior: 'smooth' }); 369 if(data.error) 370 moJWTtroubleshootPrintJWT(data.error , 'valid'); 371 else 372 moJWTtroubleshootHideJWT('valid'); 373 } 374 function moJWTtroubleshootHideJWT(place){ 375 if(place === "token"){ 376 document.getElementById("json_jwt_token_troubleshoot").style.display = "none"; 377 document.getElementById("jwt_token_troubleshoot_text").style.display = "none"; 378 } 379 else if(place === "valid"){ 380 document.getElementById("json_jwt_token_validate_troubleshoot").style.display = "none"; 381 document.getElementById("jwt_token_validate_text").style.display = "none"; 382 } 383 else{ 384 document.getElementById("data_display_troubleshoot").style.display = "none"; 385 document.getElementById("data_display_text").style.display = "none"; 386 } 387 388 389 390 } 391 function moJWTtroubleshootPrintJWT(err,place){ 392 if(err === "INVALID_CREDENTIALS") 393 { 394 document.getElementById("json_jwt_token_troubleshoot").innerHTML = `<ul style="list-style: inside;"><li>Check if username and password entered are correct.</li><li>If yes try password without special charachters.</li></ul>`; 395 document.getElementById("json_jwt_token_troubleshoot").style.display = "block"; 396 document.getElementById("jwt_token_troubleshoot_text").style.display = "inline-block"; 397 398 } 399 else if(err === "BAD_REQUEST") 400 { 401 document.getElementById("json_jwt_token_troubleshoot").innerHTML = 'Username or Password is missing.'; 402 document.getElementById("json_jwt_token_troubleshoot").style.display = "block"; 403 document.getElementById("jwt_token_troubleshoot_text").style.display = "inline-block"; 404 405 } 406 else if(err === "SEGMENT_FAULT") 407 { 408 if(place === "valid"){ 409 document.getElementById("json_jwt_token_validate_troubleshoot").innerHTML = 'JWT token you entered is of invalid format re-enter it properly.'; 410 document.getElementById("json_jwt_token_validate_troubleshoot").style.display = "block"; 411 document.getElementById("jwt_token_validate_text").style.display = "block"; 412 } 413 else{ 414 document.getElementById("data_display_troubleshoot").innerHTML = 'JWT token you entered is of invalid format re-enter it properly.'; 415 document.getElementById("data_display_troubleshoot").style.display = "block"; 416 document.getElementById("data_display_text").style.display = "block"; 417 } 418 } 419 else if(err === "INVALID_PASSWORD") 420 { 421 document.getElementById("json_jwt_token_validate_troubleshoot").innerHTML = ''; 422 document.getElementById("json_jwt_token_validate_troubleshoot").style.display = "block"; 423 document.getElementById("jwt_token_validate_text").style.display = "block"; 424 425 } 426 else if(err === "MISSING_AUTHORIZATION_HEADER") 427 { 428 429 if(place === "valid"){ 430 document.getElementById("json_jwt_token_validate_troubleshoot").innerHTML = 'JWT token field is empty.'; 431 document.getElementById("json_jwt_token_validate_troubleshoot").style.display = "block"; 432 document.getElementById("jwt_token_validate_text").style.display = "block"; 433 434 } 435 else{ 436 document.getElementById("data_display_troubleshoot").innerHTML = 'JWT token field is empty.'; 437 document.getElementById("data_display_troubleshoot").style.display = "block"; 438 document.getElementById("data_display_text").style.display = "block"; 439 440 } 441 } 442 else if(err === "INVALID_AUTHORIZATION_HEADER_TOKEN_TYPE") 443 { 444 if(place === "valid"){ 445 document.getElementById("json_jwt_token_validate_troubleshoot").innerHTML = 'JWT token is missing check the JWT token field.'; 446 document.getElementById("json_jwt_token_validate_troubleshoot").style.display = "block"; 447 document.getElementById("jwt_token_validate_text").style.display = "block"; 448 449 } 450 else{ 451 document.getElementById("data_display_troubleshoot").innerHTML = 'JWT token is missing check the JWT token field.'; 452 document.getElementById("data_display_troubleshoot").style.display = "block"; 453 document.getElementById("data_display_text").style.display = "block"; 454 455 } 456 } 457 else if(err === "UNAUTHORIZED") 458 { 459 if(place === "valid"){ 460 document.getElementById("json_jwt_token_validate_troubleshoot").innerHTML = `<ul style="list-style: inside;"><li>JWT token entered is either expired or is of different authorization flow.</li><li>Regenrate JWT token and copy past it properly.</li></ul>`; 461 document.getElementById("json_jwt_token_validate_troubleshoot").style.display = "block"; 462 document.getElementById("jwt_token_validate_text").style.display = "block"; 463 464 } 465 else{ 466 document.getElementById("data_display_troubleshoot").innerHTML = `<ul style="list-style: inside;"><li>JWT token entered is either expired or is of different authorization flow.</li><li>Regenrate JWT token and copy past it properly.</li></ul>`; 467 document.getElementById("data_display_troubleshoot").style.display = "block"; 468 document.getElementById("data_display_text").style.display = "block"; 469 470 } 471 } 472 473 474 } 475 476 477 function moJWToutput(inp, endpoint) { 291 478 // document.body.appendChild(document.createElement('pre')).innerHTML = inp; 292 479 if( endpoint === 'wp_rest_api') { 293 480 document.getElementById("json_jwt").innerHTML = inp; 294 } else { 481 } 482 483 else if(endpoint === "token"){ 295 484 document.getElementById("json_jwt_token").innerHTML = inp; 296 485 } 297 } 298 299 function syntaxHighlight(json) { 486 else{ 487 document.getElementById("json_jwt_token_validate").innerHTML = inp; 488 } 489 } 490 491 function moJWTsyntaxHighlight(json) { 300 492 json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); 301 493 return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { … … 316 508 } 317 509 318 function display_data(result) { 319 // console.log(result); 510 function moJWTdisplay_data(result) { 320 511 var data = JSON.parse(result); 321 512 var json = JSON.stringify(data, undefined, 4); … … 325 516 document.getElementById("jwt_token_api_response_text").style.display = "block"; 326 517 document.getElementById("jwt_token_api_response_text").scrollIntoView({behavior: 'smooth' }); 327 output(syntaxHighlight(json), 'wp_rest_api'); 518 moJWToutput(moJWTsyntaxHighlight(json), 'wp_rest_api'); 519 if(data.error) 520 moJWTtroubleshootPrintJWT(data.error , 'wp_rest_api'); 521 else 522 moJWTtroubleshootHideJWT('wp_rest_api'); 328 523 329 524 } -
wp-rest-api-authentication/trunk/admin/partials/flow/class-mo-api-authentication-basic-oauth.php
r2761358 r2811049 23 23 $user = get_user_by('login', $uname); 24 24 if( $user ) { 25 if(wp_check_password( $pword, $user->user_pass, $user->ID )){ 25 $valid_pass=wp_authenticate_username_password( NULL,$uname, $pword ); 26 if(!is_wp_error($valid_pass)){ 26 27 wp_set_current_user($user->ID); 27 28 return true; -
wp-rest-api-authentication/trunk/admin/partials/flow/mo-api-authentication-flow.php
r2761358 r2811049 60 60 61 61 // Save whitelist to the Options table 62 62 63 update_option('mo_api_authentication_protectedrestapi_route_whitelist', $rest_routes); 63 64 add_settings_error('ProtectedRestAPI_notices', 'settings_updated', 'Whitelist settings saved.', 'updated'); … … 82 83 $all_routes = array_keys( $wp_rest_server->get_routes() ); 83 84 $all_routes = array_map('esc_html',$all_routes); 85 86 foreach($all_routes as $key => $value){ 87 if($value === "/api/v1/token"){ 88 array_splice($all_routes,$key,1); 89 } 90 91 } 92 foreach($all_routes as $key => $value){ 93 if($value === "/api/v1/token-validate"){ 94 array_splice($all_routes,$key,1); 95 } 96 97 } 98 84 99 update_option( 'mo_api_authentication_protectedrestapi_route_whitelist', $all_routes); 85 100 } … … 156 171 } 157 172 } 173 174 $jsonfile=plugin_dir_path(__FILE__); 175 $jsonfile=rtrim($jsonfile,'/'); 176 $jsonfile=$jsonfile.'\\mo_temp_json_file.json'; 177 file_put_contents($jsonfile, $contents); 178 158 179 header('Content-Disposition: attachment; filename ='.$filename); 159 180 header('Content-Type: application/json'); 160 181 ob_clean(); 161 echo esc_html($contents); 182 @readfile($jsonfile); 183 unlink($jsonfile); 162 184 exit(); 163 185 } -
wp-rest-api-authentication/trunk/admin/partials/flow/mo-token-api-flow.php
r2761358 r2811049 19 19 function mo_api_auth_method_get_token($request) { 20 20 if( isset( $request['username'] ) && isset( $request['password'] ) ) { 21 $username = sanitize_text_field( $request['username'] ); 22 $password = sanitize_text_field( $request['password'] ); 21 $username =$request['username']; 22 $password = $request['password'] ; 23 23 24 $client_secret = sanitize_text_field( get_option('mo_api_authentication_jwt_client_secret') ); 24 25 … … 34 35 35 36 $user = get_user_by('login', $username); 36 37 37 if( $user ) { 38 38 wp_set_current_user($user->ID); 39 $valid_pass = wp_check_password( $password, $user->user_pass, $user->ID ); 39 40 $valid_pass = wp_authenticate_username_password( NULL,$username, $password ); 41 42 if(is_wp_error($valid_pass)){ 43 $valid_pass=false; 44 } 45 else{ 46 $valid_pass=true; 47 } 40 48 } 41 49 … … 126 134 { 127 135 128 if( is_user_logged_in() && empty(sanitize_text_field($_GET['mo_rest_api_test_config']))){136 if( is_user_logged_in() && empty( isset($_GET['mo_rest_api_test_config']) ? sanitize_text_field($_GET['mo_rest_api_test_config']) : "" ) ){ 129 137 return true; 130 138 } … … 144 152 $headers = array_change_key_case($headers, CASE_UPPER); 145 153 146 if (stripos(explode('?', sanitize_text_field($_SERVER['REQUEST_URI']), 2)[0], '/wp/v2') === false ){154 if (stripos(explode('?', sanitize_text_field($_SERVER['REQUEST_URI']), 2)[0], '/wp/v2') === false){ 147 155 if(get_option('mo_rest_api_protect_migrate')){ 148 156 $response = array( … … 174 182 } 175 183 } 184 185 176 186 177 187 return $response; -
wp-rest-api-authentication/trunk/includes/class-miniorange-api-authentication.php
r2761358 r2811049 159 159 $this->loader->add_action( 'admin_menu', $plugin_admin, 'mo_api_authentication_config_settings'); 160 160 $this->loader->add_action( 'admin_menu', $plugin_admin, 'mo_api_auth_admin_menu' ); 161 $this->loader->add_action( 'rest_api_init', $plugin_admin, 'register_rest_routes' ); 161 162 $this->loader->add_action( 'rest_api_init', $plugin_admin, 'mo_api_auth_initialize_api_flow' ); 162 $this->loader->add_action( 'wp_ajax_regenerate_token', $plugin_admin, 'regenerate_token' );163 $this->loader->add_action( 'wp_ajax_regenerate_client_credentials', $plugin_admin, 'regenerate_client_credentials' );164 163 $this->loader->add_action( 'wp_ajax_save_temporary_data', $plugin_admin, 'save_temporary_data' ); 165 164 } -
wp-rest-api-authentication/trunk/miniorange-api-authentication.php
r2761358 r2811049 4 4 * Plugin URI: wp-rest-api-authentication 5 5 * Description: WordPress REST API Authentication secures rest API access for unauthorized users using OAuth 2.0, Basic Auth, JWT, API Key. Also reduces potential attack factors to the respective site. 6 * Version: 2. 4.06 * Version: 2.3.1 7 7 * Author: miniOrange 8 8 * Author URI: https://www.miniorange.com … … 21 21 * Rename this for your plugin and update it as you release new versions. 22 22 */ 23 define( 'MINIORANGE_API_AUTHENTICATION_VERSION', '2. 4.0' );23 define( 'MINIORANGE_API_AUTHENTICATION_VERSION', '2.3.0' ); 24 24 // require_once plugin_dir_path( __FILE__ ) . 'admin/partials/support/class-mo-api-authentication-feedback.php'; 25 25
Note: See TracChangeset
for help on using the changeset viewer.