Compare commits

..

No commits in common. "main" and "v1.0.3" have entirely different histories.
main ... v1.0.3

9 changed files with 57 additions and 40 deletions

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

8
CHANGELOG.md Normal file
View File

@ -0,0 +1,8 @@
# CHANGE LOG
## 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

View File

@ -9,7 +9,7 @@ report:
build: build:
python3 -m pip install --upgrade setuptools wheel twine python3 -m pip install --upgrade setuptools wheel twine
python3 -m pip install --upgrade build python -m pip install --upgrade build
if [ -d "./build" ]; then sudo rm -r build; fi if [ -d "./build" ]; then sudo rm -r build; fi
if [ -d "./dist" ]; then sudo rm -r dist; fi if [ -d "./dist" ]; then sudo rm -r dist; fi

View File

@ -1 +1 @@
__version__ = "1.0.8" __version__ = "1.0.4"

View File

@ -4,6 +4,10 @@ written by: Lawrence McDaniel
date: oct-2022 date: oct-2022
usage: subclass of BaseOAuth2 Third Party Authtencation client to
handle the field mapping and data conversions between
the dict that WP Oauth returns versus the dict that Open edX
actually needs.
""" """
import json import json
from urllib.parse import urlencode from urllib.parse import urlencode
@ -12,12 +16,12 @@ from urllib.parse import urljoin
from logging import getLogger from logging import getLogger
from social_core.backends.oauth import BaseOAuth2 from social_core.backends.oauth import BaseOAuth2
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.conf import settings
User = get_user_model() User = get_user_model()
logger = getLogger(__name__) logger = getLogger(__name__)
VERBOSE_LOGGING = False VERBOSE_LOGGING = True
class WPOpenEdxOAuth2(BaseOAuth2): class WPOpenEdxOAuth2(BaseOAuth2):
@ -46,12 +50,11 @@ class WPOpenEdxOAuth2(BaseOAuth2):
# Third Party Authentication / Provider Configuration (OAuth) # Third Party Authentication / Provider Configuration (OAuth)
# setup page drop-down box titled, "Backend name:", just above # setup page drop-down box titled, "Backend name:", just above
# the "Client ID:" and "Client Secret:" fields. # the "Client ID:" and "Client Secret:" fields.
name = "wp-oauth" name = "wp-oauth"
# note: no slash at the end of the base url. Python Social Auth # 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. # might clean this up for you, but i'm not 100% certain of that.
BASE_URL = settings.FEATURES.get('WP_PROVIDER_URL') BASE_URL = "https://set-me-please.com"
# a path to append to the BASE_URL: https://oauth_host.com/oauth/ # a path to append to the BASE_URL: https://oauth_host.com/oauth/
PATH = "oauth/" PATH = "oauth/"
@ -108,9 +111,6 @@ class WPOpenEdxOAuth2(BaseOAuth2):
# list can be delimited with commas, spaces, whatever. # list can be delimited with commas, spaces, whatever.
SCOPE_SEPARATOR = " " 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. # private utility function. not part of psa.
def _urlopen(self, url): def _urlopen(self, url):
""" """
@ -409,7 +409,6 @@ class WPOpenEdxOAuth2(BaseOAuth2):
except User.DoesNotExist: except User.DoesNotExist:
return self.user_details return self.user_details
if self.UPDATE_USER_ON_LOGIN:
if (user.is_superuser != self.user_details["is_superuser"]) or ( if (user.is_superuser != self.user_details["is_superuser"]) or (
user.is_staff != self.user_details["is_staff"] user.is_staff != self.user_details["is_staff"]
): ):
@ -421,6 +420,7 @@ class WPOpenEdxOAuth2(BaseOAuth2):
username=user.username username=user.username
) )
) )
if (user.first_name != self.user_details["first_name"]) or ( if (user.first_name != self.user_details["first_name"]) or (
user.last_name != self.user_details["last_name"] user.last_name != self.user_details["last_name"]
): ):

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"
[project] [project]
name = "edx-oauth2-wordpress-backend" name = "edx-oauth2-wordpress-backend"
version = "1.0.8" version = "1.0.4"
authors = [ authors = [
{ name="Lawrence McDaniel", email="lpm0073@gmail.com" }, { name="Lawrence McDaniel", email="lpm0073@gmail.com" },
] ]
@ -17,7 +17,7 @@ classifiers = [
"Operating System :: OS Independent", "Operating System :: OS Independent",
] ]
dependencies = [ dependencies = [
"social-auth-core==4.3.0", "social-auth-core>=4.2.0",
"social-auth-app-django==5.0.0" "social-auth-app-django==5.0.0"
] ]
keywords = ["Open edX", "oauth", "Wordpress"] keywords = ["Open edX", "oauth", "Wordpress"]

View File

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

View File

@ -1,5 +1,5 @@
# Packages for testing # Packages for testing
pytest>=7.1.1 pytest==7.1.1
httpretty>=1.1.4 httpretty==1.1.4
pycodestyle>=2.8.0 pycodestyle==2.8.0
-e . -e .

View File

@ -74,9 +74,11 @@ setup(
long_description=README, long_description=README,
author="Lawrence McDaniel, lpm0073@gmail.com", author="Lawrence McDaniel, lpm0073@gmail.com",
author_email="lpm0073@gmail.com", author_email="lpm0073@gmail.com",
url="https://git.unecon.ru/gevorkyan.aa/edx-oauth2-wordpress-backend", url="https://github.com/StepwiseMath/edx-oauth2-wordpress-backend",
project_urls={ project_urls={
"Code": "https://git.unecon.ru/gevorkyan.aa/edx-oauth2-wordpress-backend" "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(), packages=find_packages(),
include_package_data=True, include_package_data=True,