Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation on configuring plugin #112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ openssl genrsa -out oidc.key 4096
openssl rsa -in oidc.key -pubout -out public.key
~~~

And make them available to the plugin as follows (this needs to be added before WordPress loads):
And make them available to the plugin as below (this needs to be added before WordPress loads). This should be added to the `wp-config.php` file of your WordPress installation. Note, that it is important to add the `define` statements before the line `require_once ABSPATH . 'wp-settings.php';`. Otherwise, your RSA keys might not be visible to the rest of the WordPress website.

~~~php
define( 'OIDC_PUBLIC_KEY', <<<OIDC_PUBLIC_KEY
Expand All @@ -50,7 +50,7 @@ define( 'OIDC_PRIVATE_KEY', file_get_contents( '/web-inaccessible/private.key' )

### Define the clients

Define your clients by adding a filter to `oidc_registered_clients` in a separate plugin file or `functions.php` of your theme or in a MU-plugin like:
Define your clients by adding a filter to `oidc_registered_clients` in a separate plugin file or `functions.php` of your theme or in a MU-plugin as below. The easiest way would be to add filter through WordPress Admin interface by going to Appearance -> Theme file editor -> choose Theme Functions (functions.php) on the right hand side menu. You can add the code to the end of the file before `?>`.
~~~php
add_filter( 'oidc_registered_clients', 'my_oidc_clients' );
function my_oidc_clients() {
Expand All @@ -66,6 +66,14 @@ function my_oidc_clients() {
}
~~~

### Check that everything works as expected
You should be able to go to `https://<your_wordpress_domain>/.well-known/openid-configuration`. This endpoint will list the endpoints of the authorization flow. Namely, three endpoints will be defined:
- `https://<your_wordpress_domain>/wp-json/openid-connect/authorize`
- `https://<your_wordpress_domain>/wp-json/openid-connect/token`
- `https://<your_wordpress_domain>/wp-json/openid-connect/userinfo`

`wp-json` is where the REST routes are defined for your WordPress website.

### Exclude URL from caching

- `example.com/wp-json/openid-connect/userinfo`: We implement caching exclusion measures for this endpoint by setting `Cache-Control: 'no-cache'` headers and defining the `DONOTCACHEPAGE` constant. If you have a unique caching configuration, please ensure that you manually exclude this URL from caching.
Expand Down