Compare commits

...

14 Commits
v1.0.5 ... main

Author SHA1 Message Date
ab0bcb151b Update dependencies and cleanup 2024-08-07 11:24:48 +03:00
a3bb22422a BASE_URL is now taken from lms.yml 2024-08-07 11:19:38 +03:00
Jeff Cohen
0d52c5902c
Merge pull request #5 from cookiecutter-openedx/version-bump
Add changelog and bump pyproject version
2024-02-01 13:28:38 -05:00
Jeff Cohen
4f9837cc75 update date 2024-02-01 18:28:28 +00:00
Jeff Cohen
b8d958f8b5 Add changelog and bump pyproject version 2024-02-01 18:27:55 +00:00
Jeff Cohen
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
Erik Martus
da8dafb627 add property to control user updates 2024-01-25 21:00:16 +00:00
lpm0073
caf3ff79a3 synch pyproject.toml requirements 2023-08-12 13:49:30 -06:00
lpm0073
dc86f9b504 add funding links 2023-04-28 14:14:32 -06:00
Jeff Cohen
7a958c8fa3
Merge pull request #3 from lpm0073/python3
bump version
2022-12-20 14:59:12 -05:00
Jeff Cohen
644799445a bump version 2022-12-20 19:49:30 +00:00
Lawrence McDaniel
3eda26893d
Merge pull request #2 from lpm0073/python3
Consistently use python3 in Makefile
2022-12-20 13:49:20 -06:00
Jeff Cohen
ef7714b3bf Changelog 2022-12-20 19:47:21 +00:00
Jeff Cohen
526a40ab84 Consistently use python3 in Makefile 2022-12-20 19:46:34 +00:00
9 changed files with 40 additions and 61 deletions

View File

@ -1,7 +0,0 @@
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

View File

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

View File

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

View File

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

View File

@ -4,10 +4,6 @@ written by: Lawrence McDaniel
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
from urllib.parse import urlencode
@ -16,12 +12,12 @@ from urllib.parse import urljoin
from logging import getLogger
from social_core.backends.oauth import BaseOAuth2
from django.contrib.auth import get_user_model
from django.conf import settings
User = get_user_model()
logger = getLogger(__name__)
VERBOSE_LOGGING = True
VERBOSE_LOGGING = False
class WPOpenEdxOAuth2(BaseOAuth2):
@ -50,12 +46,13 @@ class WPOpenEdxOAuth2(BaseOAuth2):
# Third Party Authentication / Provider Configuration (OAuth)
# setup page drop-down box titled, "Backend name:", just above
# the "Client ID:" and "Client Secret:" fields.
name = "wp-oauth"
# 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.
BASE_URL = "https://set-me-please.com"
BASE_URL = settings.FEATURES.get('WP_PROVIDER_URL')
# a path to append to the BASE_URL: https://oauth_host.com/oauth/
PATH = "oauth/"
@ -110,6 +107,9 @@ class WPOpenEdxOAuth2(BaseOAuth2):
# changed to a list. example 'basic, email, profile'. This
# 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):
@ -409,28 +409,28 @@ class WPOpenEdxOAuth2(BaseOAuth2):
except User.DoesNotExist:
return self.user_details
if (user.is_superuser != self.user_details["is_superuser"]) or (
user.is_staff != self.user_details["is_staff"]
):
user.is_superuser = self.user_details["is_superuser"]
user.is_staff = self.user_details["is_staff"]
user.save()
logger.info(
"Updated the is_superuser/is_staff flags for user {username}".format(
username=user.username
if self.UPDATE_USER_ON_LOGIN:
if (user.is_superuser != self.user_details["is_superuser"]) or (
user.is_staff != self.user_details["is_staff"]
):
user.is_superuser = self.user_details["is_superuser"]
user.is_staff = self.user_details["is_staff"]
user.save()
logger.info(
"Updated the is_superuser/is_staff flags for user {username}".format(
username=user.username
)
)
)
if (user.first_name != self.user_details["first_name"]) or (
user.last_name != self.user_details["last_name"]
):
user.first_name = self.user_details["first_name"]
user.last_name = self.user_details["last_name"]
user.save()
logger.info(
"Updated first_name/last_name for user {username}".format(
username=user.username
if (user.first_name != self.user_details["first_name"]) or (
user.last_name != self.user_details["last_name"]
):
user.first_name = self.user_details["first_name"]
user.last_name = self.user_details["last_name"]
user.save()
logger.info(
"Updated first_name/last_name for user {username}".format(
username=user.username
)
)
)
return self.user_details

View File

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

View File

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

View File

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

View File

@ -74,11 +74,9 @@ setup(
long_description=README,
author="Lawrence McDaniel, lpm0073@gmail.com",
author_email="lpm0073@gmail.com",
url="https://github.com/StepwiseMath/edx-oauth2-wordpress-backend",
url="https://git.unecon.ru/gevorkyan.aa/edx-oauth2-wordpress-backend",
project_urls={
"Code": "https://github.com/StepwiseMath/edx-oauth2-wordpress-backend",
"Issue tracker": "https://github.com/StepwiseMath/edx-oauth2-wordpress-backend/issues",
"Community": "https://stepwisemath.ai",
"Code": "https://git.unecon.ru/gevorkyan.aa/edx-oauth2-wordpress-backend"
},
packages=find_packages(),
include_package_data=True,