diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..f7ac613
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,9 @@
+# CHANGE LOG
+
+## Version 1.0.1 (2022-11-08)
+
+- add property for URL
+- add class variables for PATH, AUTHORIZATION_ENDPOINT, TOKEN_ENDPOINT, USERINFO_ENDPOINT
+- switch to urllib.parse urljoin()
+- add a Makefile
+- change documentation to reference Wordpress miniOrange OAuth / OpenID Connect Server
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..430fc7f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,40 @@
+# -------------------------------------------------------------------------
+# build a package for PyPi
+# -------------------------------------------------------------------------
+.PHONY: build
+.PHONY: requirements
+
+report:
+ cloc $(git ls-files)
+
+build:
+ python3 -m pip install --upgrade setuptools wheel twine
+ python -m pip install --upgrade build
+
+ if [ -d "./build" ]; then sudo rm -r build; fi
+ if [ -d "./dist" ]; then sudo rm -r dist; fi
+ if [ -d "./edx_oauth2_wordpress_backend.egg-info" ]; then sudo rm -r edx_oauth2_wordpress_backend.egg-info; fi
+
+ python3 -m build --sdist ./
+ python3 -m build --wheel ./
+
+ python3 -m pip install --upgrade twine
+ twine check dist/*
+
+
+# -------------------------------------------------------------------------
+# upload to PyPi Test
+# https:// ?????
+# -------------------------------------------------------------------------
+release-test:
+ make build
+ twine upload --skip-existing --repository testpypi dist/*
+
+
+# -------------------------------------------------------------------------
+# upload to PyPi
+# https://pypi.org/project/django-memberpress-client/
+# -------------------------------------------------------------------------
+release-prod:
+ make build
+ twine upload --skip-existing dist/*
diff --git a/README.rst b/README.rst
index cd5f14d..0153875 100644
--- a/README.rst
+++ b/README.rst
@@ -22,7 +22,7 @@ Open edX OAuth2 Backend for Wordpress
Overview
--------
-An Open edX oauth2 backend for `Wordpress `_ `WP OAuth `_.
+An Open edX oauth2 backend for `Wordpress `_ `miniOrange OAuth / OpenID Connect Server `_.
- `Python Social Auth custom backend implentation `_
- `WP Oauth Wordpress Plugin Documentation `_
@@ -93,9 +93,9 @@ add these settings to django.conf:
* - WPOAUTH_BACKEND_BASE_URL
- https://stepwisemath.ai
* - WPOAUTH_BACKEND_CLIENT_ID
- - see: https://stepwisemath.ai/wp-admin/admin.php?page=wo_manage_clients
+ - see: https://stepwisemath.ai/wp-admin/admin.php?page=mo_oauth_server_settings
* - WPOAUTH_BACKEND_CLIENT_SECRET
- - see: https://stepwisemath.ai/wp-admin/admin.php?page=wo_manage_clients
+ - see: https://stepwisemath.ai/wp-admin/admin.php?page=mo_oauth_server_settings
* - SCOPE
- basic email profile
* - GRANT_TYPE
@@ -115,22 +115,6 @@ add these settings to django.conf:
:alt: Open edX Django Admin Add Provider Configuration (OAuth)
-5. Optional: Configure your devops
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Cookiecutter openedx_devops build
-
-.. code-block:: shell
-
- - name: Add the edx-oauth2-wordpress-backend
- uses: openedx-actions/tutor-plugin-build-openedx-add-requirement@v1.0.0
- with:
- repository: edx-oauth2-wordpress-backend
- repository-organization: StepwiseMath
- repository-ref: main
- repository-token: ${{ secrets.PAT }}
-
-
Cookiecutter openedx_devops deployment
.. code-block:: shell
@@ -145,29 +129,9 @@ WP Oauth Plugin Configuration
This plugin enables your Open edX installation to authenticate against the WP Oauth plugin provider
in your Wordpress web site, configured as follows:
-.. image:: https://raw.githubusercontent.com/lpm0073/edx-oauth2-wordpress-backend/main/doc/wp-oauth-config.png
+.. image:: https://raw.githubusercontent.com/lpm0073/edx-oauth2-wordpress-backend/main/doc/miniorange-oauth-config.png
:width: 100%
- :alt: WP Oauth configuration page
-
-Usage in Cookiecutter
----------------------
-
-add a snippet of this form to openedx_devops/.github/workflows/build-openedx.yml
-
-.. code-block:: yaml
-
- steps:
- #------------------------------------------------------------------------
- # ... add your initialization and any preceding steps ...
- #------------------------------------------------------------------------
-
- - name: Add the edx-oauth2-wordpress-backend
- uses: openedx-actions/tutor-plugin-build-openedx-add-requirement@v1.0.0
- with:
- repository: edx-oauth2-wordpress-backend
- repository-organization: lpm0073
- repository-ref: v1.0.0
-
+ :alt: miniOrange OAuth configuration page
Sample lms log output
---------------------
diff --git a/doc/miniorange-oauth-config.png b/doc/miniorange-oauth-config.png
new file mode 100644
index 0000000..1ce75e2
Binary files /dev/null and b/doc/miniorange-oauth-config.png differ
diff --git a/oauth2_wordpress/__about__.py b/oauth2_wordpress/__about__.py
index 5becc17..5c4105c 100644
--- a/oauth2_wordpress/__about__.py
+++ b/oauth2_wordpress/__about__.py
@@ -1 +1 @@
-__version__ = "1.0.0"
+__version__ = "1.0.1"
diff --git a/oauth2_wordpress/wp_oauth.py b/oauth2_wordpress/wp_oauth.py
index 021518d..ed7ff05 100644
--- a/oauth2_wordpress/wp_oauth.py
+++ b/oauth2_wordpress/wp_oauth.py
@@ -12,6 +12,7 @@ usage: subclass of BaseOAuth2 Third Party Authtencation client to
import json
from urllib.parse import urlencode
from urllib.request import urlopen
+from urllib.parse import urljoin
from logging import getLogger
from social_core.backends.oauth import BaseOAuth2
from django.contrib.auth import get_user_model
@@ -55,6 +56,14 @@ class WPOpenEdxOAuth2(BaseOAuth2):
# might clean this up for you, but i'm not 100% certain of that.
BASE_URL = "https://set-me-please.com"
+ # a path to append to the BASE_URL: https://oauth_host.com/oauth/
+ PATH = "wp-json/moserver"
+
+ # endpoint defaults
+ AUTHORIZATION_ENDPOINT = "authorize"
+ TOKEN_ENDPOINT = "token"
+ USERINFO_ENDPOINT = "resource"
+
# The default key name where the user identification field is defined, it’s
# used in the auth process when some basic user data is returned. This Id
# is stored in the UserSocialAuth.uid field and this, together with the
@@ -204,6 +213,10 @@ class WPOpenEdxOAuth2(BaseOAuth2):
return "get_user_details() return dict"
return "unrecognized response dict"
+ @property
+ def URL(self):
+ return urljoin(self.BASE_URL, self.PATH)
+
# override Python Social Auth default end points.
# see https://wp-oauth.com/docs/general/endpoints/
#
@@ -211,21 +224,21 @@ class WPOpenEdxOAuth2(BaseOAuth2):
# so that we can include logging for diagnostic purposes.
@property
def AUTHORIZATION_URL(self) -> str:
- url = f"{self.BASE_URL}/oauth/authorize"
+ url = urljoin(self.URL, self.AUTHORIZATION_ENDPOINT)
if VERBOSE_LOGGING:
logger.info("AUTHORIZATION_URL: {url}".format(url=url))
return url
@property
def ACCESS_TOKEN_URL(self) -> str:
- url = f"{self.BASE_URL}/oauth/token"
+ url = urljoin(self.URL, self.TOKEN_ENDPOINT)
if VERBOSE_LOGGING:
logger.info("ACCESS_TOKEN_URL: {url}".format(url=url))
return url
@property
def USER_QUERY(self) -> str:
- url = f"{self.BASE_URL}/oauth/me"
+ url = urljoin(self.URL, self.USERINFO_ENDPOINT)
if VERBOSE_LOGGING:
logger.info("USER_QUERY: {url}".format(url=url))
return url
diff --git a/pyproject.toml b/pyproject.toml
index 7a9ad57..972c094 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"
[project]
name = "edx-oauth2-wordpress-backend"
-version = "1.0.0"
+version = "1.0.1"
authors = [
{ name="Lawrence McDaniel", email="lpm0073@gmail.com" },
]