43 Commits

Author SHA1 Message Date
0d52c5902c Merge pull request #5 from cookiecutter-openedx/version-bump
Add changelog and bump pyproject version
2024-02-01 13:28:38 -05:00
4f9837cc75 update date 2024-02-01 18:28:28 +00:00
b8d958f8b5 Add changelog and bump pyproject version 2024-02-01 18:27:55 +00:00
43a971c1ef Merge pull request #4 from Medality-Health/update-user-on-login
Add property to control user updates on login
2024-02-01 13:10:21 -05:00
da8dafb627 add property to control user updates 2024-01-25 21:00:16 +00:00
caf3ff79a3 synch pyproject.toml requirements 2023-08-12 13:49:30 -06:00
dc86f9b504 add funding links 2023-04-28 14:14:32 -06:00
7a958c8fa3 Merge pull request #3 from lpm0073/python3
bump version
2022-12-20 14:59:12 -05:00
644799445a bump version 2022-12-20 19:49:30 +00:00
3eda26893d Merge pull request #2 from lpm0073/python3
Consistently use python3 in Makefile
2022-12-20 13:49:20 -06:00
ef7714b3bf Changelog 2022-12-20 19:47:21 +00:00
526a40ab84 Consistently use python3 in Makefile 2022-12-20 19:46:34 +00:00
e4bb3ac4be bump to v.1.0.5 2022-12-20 13:26:39 -06:00
a88efb5335 Merge pull request #1 from Medality-Health/upgrade-social-core
Upgrade social core
2022-12-18 21:45:56 -06:00
8b33e35dde Update stable-psa.txt 2022-12-18 22:00:47 -05:00
f51c0d4b39 Upgrade social-auth-core
Allow for social-auth-core to be greater than 4.2.0 in order to be compatible with Open edX Olive which uses 4.3.0
2022-12-18 22:00:17 -05:00
4f9192f14a revert to WP OAuth Server 2022-11-09 09:40:09 -06:00
3a5f7277bf documentation 2022-11-08 20:04:18 -06:00
6eb4f65fe4 PATH needs a trailing slash 2022-11-08 20:03:21 -06:00
47ec84ca07 documentation 2022-11-08 18:44:38 -06:00
249f776d64 add URL property and class variables for PATH and endpoint values. switch to urljoin() 2022-11-08 18:40:24 -06:00
49fa25f925 documentation 2022-10-11 19:07:48 -05:00
ba970fed60 cleanup meta data 2022-10-11 15:37:53 -05:00
ebaf71e8b9 documentation 2022-10-11 15:13:36 -05:00
38c9f5e7d2 set v1.0.0 2022-10-11 15:05:40 -05:00
9cc2803842 rename the package 2022-10-11 14:59:22 -05:00
d6deb2a9bc rename the package 2022-10-11 14:58:18 -05:00
81c864ddd8 documentation 2022-10-11 14:54:54 -05:00
9aaceb80a0 rename the repo 2022-10-11 14:53:44 -05:00
2b06252dba set PyPi project name 2022-10-11 14:34:06 -05:00
ce60deefd6 bump to 1.0.2 2022-10-11 14:27:11 -05:00
bc7868a85b package for PyPi 2022-10-11 14:11:38 -05:00
a530999814 add cookiecutter usage 2022-10-10 17:55:13 -05:00
5a3d20722f brand it 2022-10-07 07:12:08 -05:00
96955b11c9 brand it 2022-10-07 07:11:24 -05:00
a7fe864ad3 brand it 2022-10-07 07:09:17 -05:00
27f8c3bbf6 brand it 2022-10-07 07:08:46 -05:00
69be20f111 brand it 2022-10-07 07:07:41 -05:00
086f0d4b1c brand it 2022-10-07 07:04:58 -05:00
6b9545bf11 brand it 2022-10-07 07:03:42 -05:00
4c6f1533ba add pre-commit 2022-10-06 21:56:33 -05:00
cc08836b67 documentation 2022-10-06 21:18:00 -05:00
2614bb2c6a scaffold build/release tools 2022-10-06 20:00:15 -05:00
16 changed files with 375 additions and 70 deletions

4
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,4 @@
# These are supported funding model platforms
github: lpm0073
patreon: lpm0073

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
.venv
venv
# Compiled python modules.
*.py[cod]
*.pyc

7
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,7 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

24
CHANGELOG.md Normal file
View File

@ -0,0 +1,24 @@
# CHANGE LOG
## Version 1.0.8 (2024-02-01)
- add support for UPDATE_USER_ON_LOGIN flag
## Version 1.0.7 (2023-08-12)
- match version requirements in pyproject.toml to those in requirements/stable-psa.txt
## Version 1.0.6 (2022-12-20)
- standardize usage of python3 in Makefile
## Version 1.0.5 (2022-12-20)
- version bumps
## Version 1.0.4 (2022-11-09)
- add property for URL
- add class variables for PATH, AUTHORIZATION_ENDPOINT, TOKEN_ENDPOINT, USERINFO_ENDPOINT
- switch to urllib.parse urljoin()
- add a Makefile

40
Makefile Normal file
View File

@ -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
python3 -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/*

View File

@ -1,10 +1,28 @@
Wordpress OAuth2 Backend for Open edX
Open edX OAuth2 Backend for Wordpress
=====================================
.. image:: https://img.shields.io/static/v1?label=pypi&style=flat-square&color=0475b6&message=edx-oauth2-wordpress-backend
:alt: PyPi edx-oauth2-wordpress-backend
:target: https://pypi.org/project/edx-oauth2-wordpress-backend/
.. image:: https://img.shields.io/badge/hack.d-Lawrence%20McDaniel-orange.svg
:target: https://lawrencemcdaniel.com
:alt: Hack.d Lawrence McDaniel
.. image:: https://img.shields.io/static/v1?logo=discourse&label=Discussions&style=flat-square&color=ff0080&message=OpenEdx
:alt: Open edX Discussions
:target: https://discuss.openedx.org/
.. image:: https://img.shields.io/static/v1?label=WP-Oauth&style=flat-square&color=1054ff&message=Server
:alt: WP Oauth
:target: https://wp-oauth.com/
|
Overview
--------
A Python Social Auth backend for `WP OAuth <https://wp-oauth.com/>`_ this is customized for use with Open edX.
An Open edX oauth2 backend for `Wordpress <https://wordpress.org//>`_ `WP OAuth Server <https://wp-oauth.com/>`_.
- `Python Social Auth custom backend implentation <https://python-social-auth.readthedocs.io/en/latest/backends/implementation.html>`_
- `WP Oauth Wordpress Plugin Documentation <https://wp-oauth.com/docs/>`_
@ -22,22 +40,20 @@ An example implementation for an Open edX installation named https://stepwisemat
1. add this package to your project's requiremets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include this repo in your project's requiremets.txt, or install it from the command line.
add this package to your project's requiremets.txt, or install it from the command line.
.. code-block:: shell
cd path/to/your/virtual/environment
source path/to/venv/bin/activate
pip install https://github.com/lpm0073/wp-oauth-backend
pip install edx-oauth2-wordpress-backend
2. subclass WPOpenEdxOAuth2
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Subclass wp_oauth_backend.wp_oauth.WPOpenEdxOAuth2, and configure for your Wordpress oauth provider.
Subclass oauth2_wordpress.wp_oauth.WPOpenEdxOAuth2, and configure for your Wordpress oauth provider.
.. code-block:: python
from wp_oauth_backend.wp_oauth import WPOpenEdxOAuth2
from oauth2_wordpress.wp_oauth import WPOpenEdxOAuth2
class StepwiseMathWPOAuth2(WPOpenEdxOAuth2):
@ -53,7 +69,14 @@ Subclass wp_oauth_backend.wp_oauth.WPOpenEdxOAuth2, and configure for your Wordp
# note: no slash at the end of the base url. Python Social Auth
# might clean this up for you, but i'm not 100% certain of that.
#
# the following will create an authorization url of https://stepwisemath.ai/wp-json/moserver/authorize
BASE_URL = "https://stepwisemath.ai"
PATH = "wp-json/moserver/"
AUTHORIZATION_ENDPOINT = "authorize"
TOKEN_ENDPOINT = "token"
USERINFO_ENDPOINT = "resource"
3. configure your Open edX lms application
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -61,9 +84,9 @@ Subclass wp_oauth_backend.wp_oauth.WPOpenEdxOAuth2, and configure for your Wordp
.. code-block:: yaml
ADDL_INSTALLED_APPS:
- "wp_oauth_backend"
- "oauth2_wordpress"
THIRD_PARTY_AUTH_BACKENDS:
- "wp_oauth_backend.wp_oauth.StepwiseMathWPOAuth2"
- "oauth2_wordpress.wp_oauth.StepwiseMathWPOAuth2"
ENABLE_REQUIRE_THIRD_PARTY_AUTH: true
add these settings to django.conf:
@ -77,9 +100,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
@ -90,31 +113,15 @@ add these settings to django.conf:
4. Configure a new Oauth2 client from the lms Django Admin console
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: doc/django-admin-1.png
.. image:: https://raw.githubusercontent.com/lpm0073/edx-oauth2-wordpress-backend/main/doc/django-admin-1.png
:width: 100%
:alt: Open edX Django Admin Add Provider Configuration (OAuth)
.. image:: doc/django-admin-2.png
.. image:: https://raw.githubusercontent.com/lpm0073/edx-oauth2-wordpress-backend/main/doc/django-admin-2.png
:width: 100%
:alt: Open edX Django Admin Add Provider Configuration (OAuth)
5. Configure your devops
~~~~~~~~~~~~~~~~~~~~~~~~
Cookiecutter openedx_devops build
.. code-block:: shell
- name: Add the wp-oauth-backend
uses: openedx-actions/tutor-plugin-build-openedx-add-requirement@v1.0.0
with:
repository: wp-oauth-backend
repository-organization: StepwiseMath
repository-ref: main
repository-token: ${{ secrets.PAT }}
Cookiecutter openedx_devops deployment
.. code-block:: shell
@ -129,7 +136,154 @@ 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:: doc/wp-oauth-config.png
.. image:: https://raw.githubusercontent.com/lpm0073/edx-oauth2-wordpress-backend/main/doc/wp-oauth-config.png
:width: 100%
:alt: WP Oauth configuration page
:alt: WP OAuth Server configuration page
Sample lms log output
---------------------
.. code-block:: shell
2022-10-06 20:17:08,832 INFO 19 [tracking] [user None] [ip 192.168.6.26] logger.py:41 - {"name": "/auth/login/stepwisemath-oauth/", "context": {"user_id": null, "path": "/auth/login/stepwisemath-oauth/", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/login", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {\"auth_entry\": [\"login\"], \"next\": [\"/dashboard\"]}, \"POST\": {}}", "time": "2022-10-06T20:17:08.832684+00:00", "event_type": "/auth/login/stepwisemath-oauth/", "event_source": "server", "page": null}
2022-10-06 20:17:09,230 INFO 19 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:216 - AUTHORIZATION_URL: https://stepwisemath.ai/oauth/authorize
[pid: 19|app: 0|req: 2/19] 192.168.4.4 () {68 vars in 1889 bytes} [Thu Oct 6 20:17:08 2022] GET /auth/login/stepwisemath-oauth/?auth_entry=login&next=%2Fdashboard => generated 0 bytes in 430 msecs (HTTP/1.1 302) 9 headers in 922 bytes (1 switches on core 0)
2022-10-06 20:17:38,485 INFO 7 [tracking] [user None] [ip 192.168.6.26] logger.py:41 - {"name": "/auth/complete/stepwisemath-oauth/", "context": {"user_id": null, "path": "/auth/complete/stepwisemath-oauth/", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://stepwisemath.ai/", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {\"redirect_state\": [\"pdbIKIcEbhjVr3Kon5VXUWWiy5kuX921\"], \"code\": [\"q0antmap4qfamd6pe24jh75pdprahpdiyitmut0o\"], \"state\": [\"pdbIKIcEbhjVr3Kon5VXUWWiy5kuX921\"], \"iframe\": [\"break\"]}, \"POST\": {}}", "time": "2022-10-06T20:17:38.484675+00:00", "event_type": "/auth/complete/stepwisemath-oauth/", "event_source": "server", "page": null}
2022-10-06 20:17:38,496 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:223 - ACCESS_TOKEN_URL: https://stepwisemath.ai/oauth/token
2022-10-06 20:17:40,197 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:230 - USER_QUERY: https://stepwisemath.ai/oauth/me
2022-10-06 20:17:40,197 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:363 - user_data() url: https://stepwisemath.ai/oauth/me?access_token=jx2zql9fw2jx9s7tayik4ybfjrmuhb7m5csb1mtl
2022-10-06 20:17:41,965 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:368 - user_data() response: {
"ID": "7",
"display_name": "Test McBugster",
"user_email": "test@stepwisemath.ai",
"user_login": "testaccount",
"user_nicename": "testaccount",
"user_registered": "2022-10-06 19:57:56",
"user_roles": [
"administrator"
],
"user_status": "0"
}
2022-10-06 20:17:41,966 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:269 - get_user_details() received wp-oauth user data response json dict: {
"ID": "7",
"display_name": "Test McBugster",
"user_email": "test@stepwisemath.ai",
"user_login": "testaccount",
"user_nicename": "testaccount",
"user_registered": "2022-10-06 19:57:56",
"user_roles": [
"administrator"
],
"user_status": "0"
}
2022-10-06 20:17:41,966 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:317 - get_user_details() processing response object
2022-10-06 20:17:41,966 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:241 - user_details.setter: new value set {
"date_joined": "2022-10-06 19:57:56",
"email": "test@stepwisemath.ai",
"first_name": "Test",
"fullname": "Test McBugster",
"id": 7,
"is_staff": true,
"is_superuser": true,
"last_name": "McBugster",
"refresh_token": "",
"scope": "",
"token_type": "",
"user_status": "0",
"username": "testaccount"
}
2022-10-06 20:17:41,967 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:345 - get_user_details() returning: {
"date_joined": "2022-10-06 19:57:56",
"email": "test@stepwisemath.ai",
"first_name": "Test",
"fullname": "Test McBugster",
"id": 7,
"is_staff": true,
"is_superuser": true,
"last_name": "McBugster",
"refresh_token": "",
"scope": "",
"token_type": "",
"user_status": "0",
"username": "testaccount"
}
2022-10-06 20:17:41,972 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:269 - get_user_details() received extended get_user_details() return dict: {
"access_token": "jx2zql9fw2jx9s7tayik4ybfjrmuhb7m5csb1mtl",
"date_joined": "2022-10-06 19:57:56",
"email": "test@stepwisemath.ai",
"expires_in": 3600,
"first_name": "Test",
"fullname": "Test McBugster",
"id": 7,
"is_staff": true,
"is_superuser": true,
"last_name": "McBugster",
"refresh_token": "",
"scope": "",
"token_type": "",
"user_status": "0",
"username": "testaccount"
}
2022-10-06 20:17:41,973 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:241 - user_details.setter: new value set {
"access_token": "jx2zql9fw2jx9s7tayik4ybfjrmuhb7m5csb1mtl",
"date_joined": "2022-10-06 19:57:56",
"email": "test@stepwisemath.ai",
"expires_in": 3600,
"first_name": "Test",
"fullname": "Test McBugster",
"id": 7,
"is_staff": true,
"is_superuser": true,
"last_name": "McBugster",
"refresh_token": "",
"scope": "",
"token_type": "",
"user_status": "0",
"username": "testaccount"
}
2022-10-06 20:17:41,973 INFO 7 [oauth2_wordpress.wp_oauth] [user None] [ip 192.168.6.26] wp_oauth.py:290 - get_user_details() returning extended get_user_details() return dict: {
"access_token": "jx2zql9fw2jx9s7tayik4ybfjrmuhb7m5csb1mtl",
"date_joined": "2022-10-06 19:57:56",
"email": "test@stepwisemath.ai",
"expires_in": 3600,
"first_name": "Test",
"fullname": "Test McBugster",
"id": 7,
"is_staff": true,
"is_superuser": true,
"last_name": "McBugster",
"refresh_token": "",
"scope": "",
"token_type": "",
"user_status": "0",
"username": "testaccount"
}
[pid: 7|app: 0|req: 2/20] 192.168.4.4 () {70 vars in 2136 bytes} [Thu Oct 6 20:17:38 2022] GET /auth/complete/stepwisemath-oauth/?redirect_state=pdbIKIcEbhjVr3Kon5VXUWWiy5kuX921&code=q0antmap4qfamd6pe24jh75pdprahpdiyitmut0o&state=pdbIKIcEbhjVr3Kon5VXUWWiy5kuX921&iframe=break => generated 0 bytes in 3549 msecs (HTTP/1.1 302) 9 headers in 612 bytes (1 switches on core 0)
2022-10-06 20:17:42,211 INFO 19 [tracking] [user None] [ip 192.168.6.26] logger.py:41 - {"name": "/register", "context": {"user_id": null, "path": "/register", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://stepwisemath.ai/", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {}, \"POST\": {}}", "time": "2022-10-06T20:17:42.211436+00:00", "event_type": "/register", "event_source": "server", "page": null}
[pid: 19|app: 0|req: 3/21] 192.168.4.4 () {70 vars in 1796 bytes} [Thu Oct 6 20:17:42 2022] GET /register => generated 37606 bytes in 177 msecs (HTTP/1.1 200) 8 headers in 600 bytes (1 switches on core 0)
2022-10-06 20:17:42,527 INFO 7 [tracking] [user None] [ip 192.168.6.26] logger.py:41 - {"name": "/stepwise/api/v1/configuration/prod", "context": {"user_id": null, "path": "/stepwise/api/v1/configuration/prod", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {}, \"POST\": {}}", "time": "2022-10-06T20:17:42.527217+00:00", "event_type": "/stepwise/api/v1/configuration/prod", "event_source": "server", "page": null}
[pid: 7|app: 0|req: 3/22] 192.168.4.4 () {68 vars in 1755 bytes} [Thu Oct 6 20:17:42 2022] GET /stepwise/api/v1/configuration/prod => generated 167 bytes in 41 msecs (HTTP/1.1 200) 6 headers in 189 bytes (1 switches on core 0)
2022-10-06 20:17:42,617 INFO 19 [tracking] [user None] [ip 192.168.6.26] logger.py:41 - {"name": "/api/user/v2/account/registration/", "context": {"user_id": null, "path": "/api/user/v2/account/registration/", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {}, \"POST\": {\"next\": [\"/dashboard\"], \"email\": [\"test@stepwisemath.ai\"], \"name\": [\"Test McBugster\"], \"username\": [\"testaccount\"], \"password\": \"********\", \"level_of_education\": [\"\"], \"gender\": [\"\"], \"year_of_birth\": [\"\"], \"mailing_address\": [\"\"], \"goals\": [\"\"], \"social_auth_provider\": [\"Stepwise\"], \"terms_of_service\": [\"true\"]}}", "time": "2022-10-06T20:17:42.616767+00:00", "event_type": "/api/user/v2/account/registration/", "event_source": "server", "page": null}
2022-10-06 20:17:42,620 INFO 7 [tracking] [user None] [ip 192.168.6.26] logger.py:41 - {"name": "/api/user/v1/validation/registration", "context": {"user_id": null, "path": "/api/user/v1/validation/registration", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {}, \"POST\": {\"name\": [\"Test McBugster\"], \"username\": [\"testaccount\"], \"password\": \"********\", \"email\": [\"test@stepwisemath.ai\"], \"terms_of_service\": [\"false\"]}}", "time": "2022-10-06T20:17:42.619453+00:00", "event_type": "/api/user/v1/validation/registration", "event_source": "server", "page": null}
[pid: 7|app: 0|req: 4/23] 192.168.4.4 () {74 vars in 1928 bytes} [Thu Oct 6 20:17:42 2022] POST /api/user/v1/validation/registration => generated 205 bytes in 85 msecs (HTTP/1.1 200) 8 headers in 282 bytes (1 switches on core 0)
2022-10-06 20:17:42,719 INFO 7 [tracking] [user None] [ip 192.168.6.26] logger.py:41 - {"name": "/api/user/v1/validation/registration", "context": {"user_id": null, "path": "/api/user/v1/validation/registration", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {}, \"POST\": {\"name\": [\"Test McBugster\"], \"username\": [\"testaccount\"], \"password\": \"********\", \"email\": [\"test@stepwisemath.ai\"], \"terms_of_service\": [\"false\"]}}", "time": "2022-10-06T20:17:42.719504+00:00", "event_type": "/api/user/v1/validation/registration", "event_source": "server", "page": null}
[pid: 7|app: 0|req: 5/24] 192.168.4.4 () {74 vars in 1928 bytes} [Thu Oct 6 20:17:42 2022] POST /api/user/v1/validation/registration => generated 205 bytes in 102 msecs (HTTP/1.1 200) 8 headers in 282 bytes (1 switches on core 0)
2022-10-06 20:17:42,816 INFO 7 [tracking] [user None] [ip 192.168.6.26] logger.py:41 - {"name": "/api/user/v1/validation/registration", "context": {"user_id": null, "path": "/api/user/v1/validation/registration", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {}, \"POST\": {\"name\": [\"Test McBugster\"], \"username\": [\"testaccount\"], \"password\": \"********\", \"email\": [\"test@stepwisemath.ai\"], \"terms_of_service\": [\"false\"]}}", "time": "2022-10-06T20:17:42.816042+00:00", "event_type": "/api/user/v1/validation/registration", "event_source": "server", "page": null}
[pid: 7|app: 0|req: 6/25] 192.168.4.4 () {74 vars in 1928 bytes} [Thu Oct 6 20:17:42 2022] POST /api/user/v1/validation/registration => generated 205 bytes in 77 msecs (HTTP/1.1 200) 8 headers in 282 bytes (1 switches on core 0)
2022-10-06 20:17:43,160 INFO 19 [audit] [user 53] [ip 192.168.6.26] models.py:2753 - Login success - user.id: 53
2022-10-06 20:17:43,221 INFO 19 [tracking] [user 53] [ip 192.168.6.26] logger.py:41 - {"name": "edx.user.settings.changed", "context": {"user_id": null, "path": "/api/user/v2/account/registration/", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": {"old": null, "new": "en", "truncated": [], "setting": "pref-lang", "user_id": 53, "table": "user_api_userpreference"}, "time": "2022-10-06T20:17:43.220899+00:00", "event_type": "edx.user.settings.changed", "event_source": "server", "page": null}
2022-10-06 20:17:43,239 INFO 19 [tracking] [user 53] [ip 192.168.6.26] logger.py:41 - {"name": "edx.user.settings.changed", "context": {"user_id": null, "path": "/api/user/v2/account/registration/", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "", "session": "a3f4ac2a5bf97f717f5745984059891b", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": {"old": false, "new": true, "truncated": [], "setting": "is_active", "user_id": 53, "table": "auth_user"}, "time": "2022-10-06T20:17:43.238965+00:00", "event_type": "edx.user.settings.changed", "event_source": "server", "page": null}
/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/__init__.py:1416: RuntimeWarning: DateTimeField Registration.activation_timestamp received a naive datetime (2022-10-06 20:17:43.246811) while time zone support is active.
warnings.warn("DateTimeField %s received a naive datetime (%s)"
2022-10-06 20:17:43,254 INFO 19 [common.djangoapps.student.models] [user 53] [ip 192.168.6.26] models.py:938 - User testaccount (test@stepwisemath.ai) account is successfully activated.
2022-10-06 20:17:43,255 INFO 19 [openedx_events.tooling] [user 53] [ip 192.168.6.26] tooling.py:160 - Responses of the Open edX Event <org.openedx.learning.student.registration.completed.v1>:
[]
2022-10-06 20:17:43,261 INFO 19 [audit] [user 53] [ip 192.168.6.26] register.py:295 - Login success on new account creation - testaccount
[pid: 19|app: 0|req: 4/26] 192.168.4.4 () {74 vars in 1881 bytes} [Thu Oct 6 20:17:42 2022] POST /api/user/v2/account/registration/ => generated 79 bytes in 1145 msecs (HTTP/1.1 200) 15 headers in 3254 bytes (1 switches on core 0)
2022-10-06 20:17:44,014 INFO 7 [tracking] [user 53] [ip 192.168.6.26] logger.py:41 - {"name": "/auth/complete/stepwisemath-oauth/", "context": {"user_id": 53, "path": "/auth/complete/stepwisemath-oauth/", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "testaccount", "session": "4b87c052d7ba72c52f84c82737834d90", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {}, \"POST\": {}}", "time": "2022-10-06T20:17:44.014681+00:00", "event_type": "/auth/complete/stepwisemath-oauth/", "event_source": "server", "page": null}
/openedx/venv/lib/python3.8/site-packages/django/db/models/fields/__init__.py:1416: RuntimeWarning: DateTimeField User.date_joined received a naive datetime (2022-10-06 19:57:56) while time zone support is active.
warnings.warn("DateTimeField %s received a naive datetime (%s)"
2022-10-06 20:17:44,100 INFO 7 [tracking] [user 53] [ip 192.168.6.26] logger.py:41 - {"name": "edx.user.settings.changed", "context": {"user_id": 53, "path": "/auth/complete/stepwisemath-oauth/", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "testaccount", "session": "4b87c052d7ba72c52f84c82737834d90", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": {"old": "2022-10-06T20:17:42.674048+00:00", "new": "2022-10-06 19:57:56", "truncated": [], "setting": "date_joined", "user_id": 53, "table": "auth_user"}, "time": "2022-10-06T20:17:44.100229+00:00", "event_type": "edx.user.settings.changed", "event_source": "server", "page": null}
[pid: 7|app: 0|req: 7/27] 192.168.4.4 () {66 vars in 3727 bytes} [Thu Oct 6 20:17:43 2022] GET /auth/complete/stepwisemath-oauth/? => generated 0 bytes in 150 msecs (HTTP/1.1 302) 10 headers in 721 bytes (1 switches on core 0)
2022-10-06 20:17:44,375 INFO 19 [tracking] [user 53] [ip 192.168.6.26] logger.py:41 - {"name": "/dashboard", "context": {"user_id": 53, "path": "/dashboard", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "testaccount", "session": "4b87c052d7ba72c52f84c82737834d90", "ip": "192.168.6.26", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "host": "web.stepwisemath.ai", "referer": "https://web.stepwisemath.ai/register", "accept_language": "en-US,en;q=0.9,es-MX;q=0.8,es-US;q=0.7,es;q=0.6", "event": "{\"GET\": {}, \"POST\": {}}", "time": "2022-10-06T20:17:44.374973+00:00", "event_type": "/dashboard", "event_source": "server", "page": null}

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

View File

@ -0,0 +1 @@
__version__ = "1.0.8"

View File

@ -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 = "oauth/"
# endpoint defaults
AUTHORIZATION_ENDPOINT = "authorize"
TOKEN_ENDPOINT = "token"
USERINFO_ENDPOINT = "me"
# The default key name where the user identification field is defined, its
# 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
@ -102,6 +111,9 @@ class WPOpenEdxOAuth2(BaseOAuth2):
# list can be delimited with commas, spaces, whatever.
SCOPE_SEPARATOR = " "
# Enable updates on the Django user object on successful WordPress login.
UPDATE_USER_ON_LOGIN = True
# private utility function. not part of psa.
def _urlopen(self, url):
"""
@ -204,6 +216,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 +227,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
@ -396,6 +412,7 @@ class WPOpenEdxOAuth2(BaseOAuth2):
except User.DoesNotExist:
return self.user_details
if self.UPDATE_USER_ON_LOGIN:
if (user.is_superuser != self.user_details["is_superuser"]) or (
user.is_staff != self.user_details["is_staff"]
):
@ -407,7 +424,6 @@ class WPOpenEdxOAuth2(BaseOAuth2):
username=user.username
)
)
if (user.first_name != self.user_details["first_name"]) or (
user.last_name != self.user_details["last_name"]
):

View File

@ -1,3 +1,27 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"
[project]
name = "edx-oauth2-wordpress-backend"
version = "1.0.8"
authors = [
{ name="Lawrence McDaniel", email="lpm0073@gmail.com" },
]
description = "An Open edX Python Social Auth backend for Wordpress"
readme = "README.rst"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"social-auth-core==4.3.0",
"social-auth-app-django==5.0.0"
]
keywords = ["Open edX", "oauth", "Wordpress"]
[project.urls]
"Homepage" = "https://github.com/lpm0073/edx-oauth2-wordpress-backend"
"Bug Tracker" = "https://github.com/lpm0073/edx-oauth2-wordpress-backend/issues"

31
release.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
#------------------------------------------------------------------------------
# written by: Lawrence McDaniel
# https://lawrencemcdaniel.com
#
# date: oct-2022
#
# usage: a work in progress. build package and upload to PyPi.
# https://pypi.org/project/edx-oauth2-wordpress-backend/
# https://pypi.org/project/edx-oauth2-wordpress-backend-lpm0073/
#
# see: https://www.freecodecamp.org/news/how-to-create-and-upload-your-first-python-package-to-pypi/
#------------------------------------------------------------------------------
python -m pip install --upgrade build
sudo rm -r build
sudo rm -r dist
sudo rm -r edx_oauth2_wordpress_backend.egg-info
python3 -m build --sdist ./
python3 -m build --wheel ./
python3 -m pip install --upgrade twine
twine check dist/*
# PyPi test
twine upload --skip-existing --repository testpypi dist/*
# PyPi
#twine upload --skip-existing dist/*

View File

@ -1,3 +1,5 @@
# Latest Python Social Auth
social-auth-app-django
social-auth-core
twine
build

View File

@ -1,3 +1,3 @@
# Stable Python Social Auth, found in Open edX Nutmeg
# Stable Python Social Auth, found in Open edX Olive
social-auth-app-django==5.0.0
social-auth-core==4.2.0
social-auth-core==4.3.0

View File

@ -20,7 +20,7 @@ def load_readme():
def load_about():
about = {}
with io.open(
os.path.join(HERE, "wp_oauth_backend", "__about__.py"),
os.path.join(HERE, "oauth2_wordpress", "__about__.py"),
"rt",
encoding="utf-8",
) as f:
@ -65,7 +65,7 @@ ABOUT = load_about()
VERSION = ABOUT["__version__"]
setup(
name="wp-oauth-backend",
name="edx-oauth2-wordpress-backend",
version=VERSION,
description=(
"An OAuth backend for the WP OAuth Wordpress Plugin, "
@ -74,17 +74,17 @@ setup(
long_description=README,
author="Lawrence McDaniel, lpm0073@gmail.com",
author_email="lpm0073@gmail.com",
url="https://github.com/StepwiseMath/wp-oauth-backend",
url="https://github.com/StepwiseMath/edx-oauth2-wordpress-backend",
project_urls={
"Code": "https://github.com/StepwiseMath/wp-oauth-backend",
"Issue tracker": "https://github.com/StepwiseMath/wp-oauth-backend/issues",
"Code": "https://github.com/StepwiseMath/edx-oauth2-wordpress-backend",
"Issue tracker": "https://github.com/StepwiseMath/edx-oauth2-wordpress-backend/issues",
"Community": "https://stepwisemath.ai",
},
packages=find_packages(),
include_package_data=True,
package_data={"": ["*.html"]}, # include any templates found in this repo.
zip_safe=False,
keywords="WP OAuth",
keywords="Open edX, oauth, Wordpress",
python_requires=">=3.7",
install_requires=load_requirements("requirements/stable-psa.txt"),
classifiers=[

View File

@ -1 +0,0 @@
__version__ = "1.0.0"