Skip to content

Commit 33efb31

Browse files
authored
Update README.md
1 parent 39fb337 commit 33efb31

File tree

1 file changed

+0
-256
lines changed

1 file changed

+0
-256
lines changed

README.md

Lines changed: 0 additions & 256 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,6 @@ We will start by filling out config.json
110110
4. From there the "Click to Reveal Token" text will be displayed. Once you click that it will give you a text string. This will be pasted into the first property of the config.json.
111111
![https://i.imgur.com/12RIZuV.png](https://i.imgur.com/12RIZuV.png)
112112

113-
**features - wordpress**
114-
* This property indicates whether you will be wanting to connect Verifier to your [WordPress](#wordpress) site. If so, make sure "Yes" is typed into the field, otherwise leave it at no.
115-
If you would like to connect to WordPress, please see the [WordPress](#wordpress) section of the documentation.
116-
117-
**features - connection**
118-
* Currently Oauth2 is the only available authentication type supported. It is secure and fairly universal so there may not be any need to add any other types, if there is, additional options and instructions will be added. Until that time, leave the default of "Oauth2".
119-
120-
**miscsettings - webaddress**
121-
* If you are going to be connecting Verifier to [WordPress](#wordpress) you will need to fill in the address of your [WordPress](#wordpress) site. Note that if your actual [WordPress](#wordpress) site is located in a subdirectory (ex. http://mysite.com/wordpress) you will need to put in the full path to your install including the subdirectory.
122-
123113
**miscsettings - requireemail**
124114
*(This setting is required when using the [WordPress](#wordpress) integration, as it is how it will locate the users account but can also be used without the integration)*
125115

@@ -206,31 +196,6 @@ The other options below only need to be changed / filled out if you are going to
206196
ex. If you type "verifier_" into the prefix the table names in the database will come out as `verifier_table_name` as opposed to just `table_name` )
207197
* **charset** Chances are you will not need to modify the character set, but if you do, you can. If you don't know what it is or you are in doubt, just leave it as is.
208198

209-
----
210-
<a name="wpconfig"></a>
211-
## wordpress.json
212-
Please see the WordPress section under the Explanations heading for details on how to create an Oauth2 WordPress connection and obtain the following information.
213-
214-
(It is advised that you create a new WordPress account on your site which will be used only as a "service account" that Verifier will use to be able to adjust permissions of your users when they verify. Please see the "User Role Editor" Plugin section for more information.)
215-
216-
These settings allow you to connect Verifier to your WordPress site in order to give your users access to protected pages or download sections you may have.
217-
218-
Please note that an active account and email address from the user is required in order for Verifier to locate the user and apply the permissions.
219-
220-
221-
**siteaddress**: "https://example.com/", (Make sure the site address is https:// and has a trailing '/' at the end.)
222-
**client_id**: "exampleclientid123123ABCabC",
223-
**client_secret**: "exampleclientid123123ABCabC123123123123",
224-
**redirect**: "https://example.com/?_wpoauth_callback=standards",
225-
**appname**: "Verifier", (Change this to whatever you named the application you created within the WP-Oauth Server plugin in order to create the above keys.)
226-
227-
228-
The below addresses should stay the default unless you manually change them within the WP-Oauth plugin.
229-
Make sure these addresses (if changed) do *not* have a leading or trailing '/' at the beginning.
230-
**accessurl**: "oauth/token",
231-
**authorizeurl**: "oauth/authorize",
232-
**granttype**: "authorization_code",
233-
234199
----
235200
<a name="explanations"></a>
236201
# Explanations
@@ -341,229 +306,8 @@ Below is an example of how config.json and wordpress.json might look to show mat
341306
342307
343308
```
344-
345-
<a name="wordpress"></a>
346-
# WordPress
347-
If using the WordPress integration you will need the following plugins.
348-
349-
* [User Role Editor](https://wordpress.org/plugins/user-role-editor/) - Used to easily create additional user permission roles in WordPress to allow much finer control of what the role has access to.
350-
* [WP Oauth Server](https://wordpress.org/plugins/oauth2-provider/) - Used to create and maintain the Oauth2 secure connection between Verifier and your WordPress site.
351-
* [PHP Code Snippets](https://wordpress.org/plugins/insert-php/) - This allows you to place the necessary PHP code required to retrieve back the users email address into your admin panel. Alternatively you can paste the code directly into your themes functions.php file.
352-
353-
(Only needed if you have trouble connecting)
354309

355-
* [Advanced Access Manager](https://wordpress.org/plugins/advanced-access-manager/) - If you find you are unable to communicate with your WordPress site once everything is configured, you may need this to make sure the REST API is enabled.
356-
357-
<a name="plugins"></a>
358-
## Plugins
359-
<a name="roleeditor"></a>
360-
### User Role Editor
361-
362-
Note: It is advised that you create a new WordPress account on your site which will be used only as a "service account" that Verifier will use to be
363-
able to adjust permissions of your users when they verify. Please see the bottom of this section for instructions on creating a new role for your "service account" user.
364-
365-
1. Once you install [User Role Editor](https://wordpress.org/plugins/user-role-editor/) make sure it is enabled. On the plugins page under "User Role Editor" There is a
366-
settings page in which you can make adjustments as you see fit. Under "Default Roles" you can select one or more roles that you would like to be applied to new users of your site
367-
but typically the default settings are fine.
368-
![https://i.imgur.com/G496YLg.png](https://i.imgur.com/G496YLg.png)
369-
370-
2. Under the "Users" main menu on the side bar you will find the "User Role Editor" configuration menu.
371-
![https://i.imgur.com/0o1K8WW.png](https://i.imgur.com/0o1K8WW.png)
372-
373-
3. On the right hand side of this menu screen you will see options to add/rename/delete roles.
374-
![https://i.imgur.com/Erufbpb.png](https://i.imgur.com/Erufbpb.png)
375-
376-
4. You can create new roles that you would like Verifier to be able to change your users to using the "Add Role" button.
377-
The "Role name (ID)" is what you will need to put into Verifiers wordpress.json config under "Wordpress Settings" and then "assets".
378-
![https://i.imgur.com/MYRTHsy.png](https://i.imgur.com/MYRTHsy.png)
379-
380-
5. Once a new role is created you will have to use the menu to assign what permissions you would like that role to have access to.
381-
* These will be specific to your site and setup.
382-
* You might have a plugin to handle downloads on your site that require permission to be able to download them.
383-
* You might have a WordPress forum plugin that restricts or allows access based on role.
384-
You can configure it to allow the roles you created for your assets to be granted access to those. These decisions are up to you.
385-
386-
387-
**Creating a new role for service account.**
388-
Once you have a new account to be used, if you have finished the steps above for setting
389-
up the "User Role Editor" plugin, from the "User Role Editor menu select "Add Role", you can leave the "Make copy of:" box blank so that the role has no permission at first.
390-
You can name it whatever you like, such as "Verifier" or similar so you know what it is for.
391-
1. Once the role is created in "User Role Editor", in the permission window make sure the new role you created is selected from the top drop down box:
392-
![https://i.imgur.com/4kP8XMK.png](https://i.imgur.com/4kP8XMK.png)
393-
394-
2. Then scroll down in the list until you locate the permission named "promote_users". Check this box and hit the "Update" button to the right to apply this permission to the new role.
395-
![https://i.imgur.com/N9ovmuv.png](https://i.imgur.com/N9ovmuv.png)
396-
397-
398-
3. Then go to the "All Users" menu in the main left hand menu.
399-
![https://i.imgur.com/hfm9Iz1.png](https://i.imgur.com/hfm9Iz1.png)
400-
401-
4. Click on your service account user to open the settings menu for that user and scroll down until you find the "Additional Capabilities" section.
402-
Under the drop down titled "Other Roles" place a check mark next to the new role you just created and then hit "Update User" at the bottom.
403-
Your service account now has the ability to edit user permissions.
404-
405310
----------------------------------------------------------------------------------------------------------------------------------------
406-
<a name="oauth"></a>
407-
### WP Oauth Server
408-
* Install the following plugin into your WordPress site and activate it. **[WP Oauth Server](https://wordpress.org/plugins/oauth2-provider/)**
409-
410-
1. Once WP Oauth Server is installed you will be able to locate it's settings in your admin panel under the tab "Oauth Server".
411-
![https://i.imgur.com/vk6wVTo.png](https://i.imgur.com/vk6wVTo.png)
412-
413-
414-
2. First click on the "Settings" tab under the "Oauth Server" menu tab.
415-
![https://i.imgur.com/ew1j0I2.png](https://i.imgur.com/ew1j0I2.png)
416-
417-
418-
3. Select the checkbox for "Oauth Server Enabled" to turn the Oauth2 communication on and press the "Save Changes" button.
419-
![https://i.imgur.com/K4Sdq81.png](https://i.imgur.com/K4Sdq81.png)
420-
421-
422-
4. Select the "Advanced Configuration" tab at the top.
423-
![https://i.imgur.com/HZs0UxN.png](https://i.imgur.com/HZs0UxN.png)
424-
425-
426-
5. Enable the checkboxes for "Authorization Code" and "Allow Implicit" if they are not both already enabled.
427-
![https://i.imgur.com/GfuJp50.png](https://i.imgur.com/GfuJp50.png)
428-
429-
430-
6. Under "Misc Settings" enable the "Require Exact Redirect URI" option.
431-
![https://i.imgur.com/dmI3lpY.png](https://i.imgur.com/dmI3lpY.png)
432-
433-
434-
7. **(Important)** Under the "Token Lifetimes (Global)" section set the value of "Access Token Lifetime" to a value very high. I have tested and recommend a value of around 599999999.
435-
This value is the amount of time in seconds that the secured connection between Verifier and your WordPress site will be allowed. The value of 599999999 is 19 years.
436-
You can adjust it as you wish but know that if the connection times out due to too short of a duration you will have to go through the Oauth2 authentication process again in order for
437-
Verifier to communicate with your WordPress site again and functionality fill be lost between them until you do.
438-
![https://i.imgur.com/YxrC6pb.png](https://i.imgur.com/YxrC6pb.png)
439-
440-
441-
8. Once those options and values are set press the "Save Changes" button and then select the "Clients" menu tab.
442-
![https://i.imgur.com/R8NoFkM.png](https://i.imgur.com/R8NoFkM.png)
443-
444-
445-
9. Select the "Add New Client" option at the top of the Clients page.
446-
![https://i.imgur.com/8OfLxq8.png](https://i.imgur.com/8OfLxq8.png)
447-
448-
10. Select the "Authorization Code" and "Implicit" checkboxes if they are not selected already. Then create a name for this application.
449-
It is recommended to use the name "Verifier" so that if you ever need to remember or identify what it is, you will easily be able to. Not that whatever name you choose will have to be put into the wordpress.json config, so do not include any spaces or special characters.
450-
![https://i.imgur.com/UsN6kxv.png](https://i.imgur.com/UsN6kxv.png)
451-
452-
11. For Redirect URI you will want to use the following value but you must put your sites URL in front of it. (Site URL must be using a SSL certificate to allow https:// connections. Please see the "SSL" section of the Explanations heading for assistance obtaining a free SSL certificate for your site.)
453-
* `?_wpoauth_callback=standards`
454-
* ex. If your site is https://example.com/ you will enter the following into the box:
455-
`https://example.com/?_wpoauth_callback=standards`
456-
457-
12. Under "Advanced Options" you will need to select the user you created specifically for Verifier to use to be able to change your users permissions.
458-
This user must have "promote_users" capability in order to be able to make changes to user roles. This can be applied to a user using the above "User Role Editor" plugin.
459-
460-
13. Once these have been filled out select the "Create Client" button at the bottom left. The page will refresh and you should then see additional fields that look like the below:
461-
![https://i.imgur.com/UnBwRFB.png](https://i.imgur.com/UnBwRFB.png)
462-
463-
14. You will then take the following values from the page and copy - paste then into the wordpress.json file in their corresponding location.
464-
* Client Name -> appname
465-
* Redirect URI -> redirect
466-
* Client ID -> client_id
467-
* Client Secret -> client_secret
468-
469-
Based on the example image above the "WordPress Connection" section of wordpress.json would look like this:
470-
471-
```
472-
oauth2:{
473-
siteaddress: "https://example.com/",
474-
client_id: "XraP4ejzqzwxgDr8xpzFQDAp6sNP8lh6NrVRGer6",
475-
client_secret: "OXE5A6d8wMNmqoLwQymZUD5H51zLg0S4XwaxDnF9",
476-
redirect: "https://example.com/?_wpoauth_callback=standards",
477-
appname: "Verifier",
478-
accessurl: "oauth/token",
479-
authorizeurl: "oauth/authorize",
480-
granttype: "authorization_code",
481-
},
482-
483-
```
484-
----------------------------------------------------------------------------------------------------------------------------------------
485-
<a name="snippets"></a>
486-
### PHP Code Snippets
487-
Note that if you prefer to add the code manually instead of following this route, you certainly can. There area number of plugins to accomplish this,
488-
and a number of ways to go about it.
489-
* This method has been tested as well as the following method.
490-
* You can locate the file "functions.php" in your current themes folder and you can paste the code from step 3 below in there manually.
491-
492-
493-
----
494-
If using PHP Code Snippets follow the below steps:
495-
496-
497-
1. Once [PHP Code Snippets](https://wordpress.org/plugins/insert-php/) is installed you will find it in the left menu of your admin panel.
498-
![https://i.imgur.com/u3SHNtt.png](https://i.imgur.com/u3SHNtt.png)
499-
500-
501-
2. You will need to select "+ Add snippet" from the top of the PHP Code Snippets menu page.
502-
![https://i.imgur.com/o2vDOAS.png](https://i.imgur.com/o2vDOAS.png)
503-
504-
505-
506-
3. Create a name for the snippet (can be whatever you like, such as "Custom API Endpoint") and then paste in the following code block in the box titled "Enter the code for your snippet".
507-
What the following code block does is adds a new REST API endpoint that Verifier will be able to call during the invoice verification process to get the user ID of
508-
the user based on their email address. It also will tell Verifier what roles the user already has so that it can add the additional new role while retaining the current role
509-
instead of replacing it with the new role. This means that if you have other plugins or permissions and settings already in place on that user, they will remain intact.
510-
511-
```
512-
add_action( 'rest_api_init', function () {
513-
register_rest_route( 'instance/v1', 'email/(?P<stringvar>[^/]+)', array(
514-
'methods' => 'GET',
515-
'callback' => 'user_email',
516-
'permission_callback' => function () {
517-
return current_user_can( 'promote_users' );
518-
},
519-
) );
520-
});
521-
522-
function user_email( $data ) {
523-
524-
// Get user by their email address
525-
$user = get_user_by( 'email', $data[ 'stringvar' ] );
526-
$userId = $user->ID;
527-
$userroles = $user->roles;
528-
$user_data = array('id' => $userId, 'roles' => $userroles, 'email' => $data['stringvar']);
529-
wp_reset_postdata();
530-
531-
return rest_ensure_response($user_data);
532-
}
533-
```
534-
535-
4. After pasting the code into the "Enter the code for your snippet" box, select the "Run everywhere" option below that under "Where to execute the code?" section.
536-
![https://i.imgur.com/6OKpBcI.png](https://i.imgur.com/6OKpBcI.png)
537-
538-
5. When completed, select the "Publish" button in the top right section of the page to activate the functionality.
539-
![https://i.imgur.com/mzSajRn.png](https://i.imgur.com/mzSajRn.png)
540-
541-
542-
543-
----------------------------------------------------------------------------------------------------------------------------------------
544-
<a name="finalsteps"></a>
545-
## WordPress integration and Oauth2 setup - Final Step
546-
To use the WordPress integration you will need to enable 4 settings in the config files as seen below:
547-
* config.json - wordpress: "Yes",
548-
* config.json - webaddress: "https://example.com/", (You will need to put in your website address. Include a trailing "/" at the end.)
549-
* config.json - requireemail: "Yes",
550-
* wordpress.json - applyrole: "Yes",
551-
552-
Once those are enabled, you have configured the dbconfig.json and ran the database creation command, and you have setup
553-
the prerequisite WordPress plugins you are ready to finalize the WordPress connection.
554-
555-
1. If Verifier is up and running send a private message to the Verifier bot containing the following command:
556-
* `!cmdwpsetup`
557-
2. You will be prompted to click on a link to your site which will establish access between Verifier and your site. If you are not logged in already, you will be prompted to login to approve this.
558-
559-
3. Once the connection has been approved you will be redirected to your sites main page but in the URL bar of your browser you will see at the end of your sites URL it will have the text `code=` as seen below:
560-
Copy and paste the code that comes after the `code=` (as seen highlighted below) back into the Discord private message with your Verifier bot and hit enter. This will complete the connection between Verifier and WordPress.
561-
If you receive a reply back from Verifier stating "Connection successfully created." then everything worked as it should.
562-
![https://i.imgur.com/T3XmBFz.png](https://i.imgur.com/T3XmBFz.png)
563-
564-
Note that there is a 30 second time limit from the time you click the link in Discord, approve the connection, and copy and paste the code back into Discord. If you do not make it in time and you get the message "Connection not established." you simply have to try again.
565-
566-
4. Finally, restart the Verifier application in order for the newly created connection to be re-established using the new authentication token and you should be good to go!
567311

568312
----
569313
<a name="commands"></a>

0 commit comments

Comments
 (0)