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

Add claims_supported to discovery info, without breaking the API #1069

Merged
merged 4 commits into from
Jan 23, 2022

Conversation

Natureshadow
Copy link
Contributor

@Natureshadow Natureshadow commented Jan 4, 2022

** Please do not squash the commits. I analyse my FOSS contributions automatically and really want to track commits I made.**

Description of the Change

This is a second shot at #967, after the drama with #1066 and #1068 ;).

It re-introduces the same change @AndreaGreco proposed, and in fact, it supports their exact desired API for get_additional_claims. In addition, it supports the "traditional" API for get_additional_claims getting passed a request directly and producing data directly.

I chose to support both due to the rationale explained in the docs in this PR.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

@Natureshadow Natureshadow requested a review from n2ygk January 4, 2022 23:00
@Natureshadow Natureshadow marked this pull request as ready for review January 4, 2022 23:02
@codecov
Copy link

codecov bot commented Jan 4, 2022

Codecov Report

Attention: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.58%. Comparing base (4b13743) to head (7befb8b).
Report is 200 commits behind head on master.

Files Patch % Lines
oauth2_provider/oauth2_validators.py 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1069      +/-   ##
==========================================
- Coverage   96.59%   96.58%   -0.02%     
==========================================
  Files          32       32              
  Lines        1764     1787      +23     
==========================================
+ Hits         1704     1726      +22     
- Misses         60       61       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Natureshadow
Copy link
Contributor Author

The Python 3.8 tests failing is probably not my fault, as I read it…

@Natureshadow Natureshadow reopened this Jan 5, 2022
@n2ygk n2ygk added this to the 1.7.0 milestone Jan 5, 2022
@AndreaGreco
Copy link
Contributor

I do a brief check seems okay.
Thanks for your review

@n2ygk
Copy link
Member

n2ygk commented Jan 5, 2022

@Natureshadow

** Please do not squash the commits. I analyse my FOSS contributions automatically and really want to track commits I made.**

We routinely squash commits as well as rebase them so as not to clutter the project's commit history with a lot of "noise" for a single feature PR. Presumably you can track your commits in your forked repo?

@n2ygk
Copy link
Member

n2ygk commented Jan 5, 2022

@Natureshadow

The Python 3.8 tests failing is probably not my fault, as I read it…

Py38 is the version used for flake8 (no point in running it for multiple different python versions). If you look at the details of that step you'll see:

  ./oauth2_provider/views/oidc.py:67:44: BLK100 Black would make changes.
  ./tests/test_oidc_views.py:32:34: BLK100 Black would make changes.
  ./tests/test_oidc_views.py:32:34: Q000 Single quotes found but double quotes preferred
  ./tests/test_oidc_views.py:59:34: Q000 Single quotes found but double quotes preferred
  ./tests/test_oidc_views.py:152:1: E302 expected 2 blank lines, found 0
  ./tests/test_oidc_views.py:155:1: E302 expected 2 blank lines, found 1
  ./tests/test_oidc_views.py:180:1: E302 expected 2 blank lines, found 1
  ERROR: InvocationError for command /home/runner/work/django-oauth-toolkit/django-oauth-toolkit/.tox/flake8/bin/flake8 . (exited with code 1)

I recommend running tox locally before pushing. Running tox runs the full set of tests and takes a while. I frequently run something like tox -e py39-dj32 just to test one version, if the changes are small, but always run the full test before my final push and creation of PR. For checking the flake8 errors, run tox -e flake8:

(dot-venv) django-oauth-toolkit$ gh pr checkout 1069
remote: Enumerating objects: 64, done.
remote: Counting objects: 100% (64/64), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 53 (delta 48), reused 51 (delta 46), pack-reused 0
Unpacking objects: 100% (53/53), 8.44 KiB | 91.00 KiB/s, done.
From github.com:jazzband/django-oauth-toolkit
 * [new ref]         refs/pull/1069/head -> claims-discovery-info
Switched to branch 'claims-discovery-info'
(dot-venv) django-oauth-toolkit$ tox -e flake8
flake8 installed: black==21.12b0,click==8.0.3,django-oauth-toolkit==1.6.1,flake8==4.0.1,flake8-black==0.2.3,flake8-isort==4.1.1,flake8-quotes==3.3.1,isort==5.10.1,mccabe==0.6.1,mypy-extensions==0.4.3,pathspec==0.9.0,platformdirs==2.4.0,pycodestyle==2.8.0,pyflakes==2.4.0,testfixtures==6.18.3,toml==0.10.2,tomli==1.2.3,typing_extensions==4.0.1
flake8 run-test-pre: PYTHONHASHSEED='1965272959'
flake8 run-test: commands[0] | flake8 /Users/ac45/src/django-oauth-toolkit
./tests/test_oidc_views.py:32:34: BLK100 Black would make changes.
./tests/test_oidc_views.py:32:34: Q000 Single quotes found but double quotes preferred
./tests/test_oidc_views.py:59:34: Q000 Single quotes found but double quotes preferred
./tests/test_oidc_views.py:152:1: E302 expected 2 blank lines, found 0
./tests/test_oidc_views.py:155:1: E302 expected 2 blank lines, found 1
./tests/test_oidc_views.py:180:1: E302 expected 2 blank lines, found 1
./oauth2_provider/views/oidc.py:67:44: BLK100 Black would make changes.
ERROR: InvocationError for command /Users/ac45/src/django-oauth-toolkit/.tox/flake8/bin/flake8 . (exited with code 1)
______________________________________________________________________ summary ______________________________________________________________________
ERROR:   flake8: commands failed

@Natureshadow
Copy link
Contributor Author

Natureshadow commented Jan 5, 2022 via email

@n2ygk
Copy link
Member

n2ygk commented Jan 5, 2022

What I can offer is squashing myself, but if you want my contribution, the commit in the master branch has to carry my identity as author.

Please do squash your commits -- or are they really @AndreaGreco's?, along with fixing the flake8 error.

Squashing and rebasing in master is an anti-pattern though. Just don't do it. Educate PR authors to make meaningful commits instead, then keep history intact.

It's rebasing in the feature branch that we try to do; not in master.

We can agree to disagree. There are religious arguments on both sides. Having a commit history for a PR that is full of noise is not helpful, especially of merges of master to get caught up vs. a clean rebase.

@Natureshadow
Copy link
Contributor Author

Natureshadow commented Jan 5, 2022 via email

@n2ygk
Copy link
Member

n2ygk commented Jan 5, 2022

Right. Such noise should be removed before merging. But every logical step has to remain one commit, even after merging. Merging several logical steps into one is plain wrong. Having my commits correctly attriibuted is not religious – it is what I expect as reward for doing work free of charge. If you cannot ensure my work remains correctly attriibuted, please do not merge it. 5 Jan 2022 17:51:35 Alan Crosswell @.***>:

We can agree to disagree. There are religious arguments on both sides. Having a commit history for a PR that is full of noise is not helpful, especially of merges of master to get caught up vs. a clean rebase.

We are all volunteers here and I am feeling very demotivated at the moment. Thanks for that.

@Natureshadow
Copy link
Contributor Author

Natureshadow commented Jan 5, 2022 via email

@n2ygk
Copy link
Member

n2ygk commented Jan 5, 2022

Nobody's trying to take away credit for your or anyone else's contributions. Your contributions are valued and you are listed as the Author of commits as well as explicitly credited in the AUTHORS file with the reviewers listed as co-authors.

Your threatening tone (do this and "never see me again") is unfortunate, dispiriting and demotivating for all of us. Perhaps this is just an unfortunate aspect of flaming someone you've never spoken to in person.

@Natureshadow
Copy link
Contributor Author

Natureshadow commented Jan 5, 2022

Your contributions are valued and you are listed as the Author of commits

That is all I am asking for. If you do ensure that what I commit under my name still is committed under my name after merging, everything is fine.

However, that was not the case for the original PR by @AndreaGreco et al – two contributors lost attribution for their commits in that case, and all I am asking from you is that you do not do this when handling my commits.

Your threatening tone (do this and "never see me again") is unfortunate, dispiriting and demotivating for all of us. Perhaps this is just an unfortunate aspect of flaming someone you've never spoken to in person.

The intention is not to threaten you. But we all have a base line for what we do work for, and my baseline is that I keep my commits. I do coding work for FOSS projects, I donate money to FOSS projects, and what I ask in return is to keep my commits. It is the only thing I ask for when working for FOSS, and I expect that this base line is not undercut.

I don't know what it is, but I am certain such a base line exists for you as well, and that you expect others to respect it. My baseline is the above, and I ask you to respect it. No more, no less.

@n2ygk
Copy link
Member

n2ygk commented Jan 5, 2022

I contribute to a couple of projects including this one and learned that it's common practice to rebase and force-push feature branches before they are merged and to squash-merge to the main branch to keep the history clean. Your concerns regarding squash-merge are news to me. Googling the issue finds strong opinions pro- and con.

Meanwhile I see @AndreaGreco as the author in the commit that I unfortunately had to revert, so I'm confused. It's right there in the history, including some noise from merging master onto this PR instead of rebasing.

Are we talking about the same thing?

commit 3a9541f903f8f945ff3f75a13b4953091717fffa
Author: Andrea Greco <[email protected]>
Date:   Fri Nov 19 09:01:04 2021 +0100

    OpenID: Add claims to Well know (#967)
    
    * OpenID: Claims: Add claims inside well-known
    
    Some client can't use userinfo, and get propelty from claims.
    Add claims key inside wellknow.
    
    * OpenID: Claims: Additional test in well-know update test
    
    * OpenID: Claims: Docs: Add docs wellknow claims
    
    * [pre-commit.ci] auto fixes from pre-commit.com hooks
    
    for more information, see https://pre-commit.ci
    
    Co-authored-by: Asif Saif Uddin <[email protected]>
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: Andrew Chen Wang <[email protected]>

@Natureshadow
Copy link
Contributor Author

Meanwhile I see @AndreaGreco as the author in the commit that I unfortunately had to revert, so I'm confused. It's right there in the history, including some noise from merging master onto this PR instead of rebasing.

    Co-authored-by: Asif Saif Uddin <[email protected]>
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: Andrew Chen Wang <[email protected]>

I see two other people listed there. I have not investigated what their original commits contained.

In any case, again repeating myself: If my contribution is committed to master under my name as commit author, everything is fine.

@Natureshadow
Copy link
Contributor Author

I recommend running tox locally before pushing.

That's not that easy, because I do not have old Python versions available. Maybe the non-version-dependent checks should use the default python3 instead of a fixed version.

In any case, trying to run flake8 manually now, and see what to fix.

@Natureshadow Natureshadow force-pushed the claims-discovery-info branch from 28eba81 to 1364162 Compare January 5, 2022 21:49
@Natureshadow
Copy link
Contributor Author

@n2ygk I fixed the lint errors (squashing the lint fixes into the original commits). Is the commit history now in a state in which you can merge it verbatim, or do you want me to clean up something else?

@Natureshadow Natureshadow force-pushed the claims-discovery-info branch 2 times, most recently from 46122c1 to b3c4a4e Compare January 5, 2022 21:57
@n2ygk
Copy link
Member

n2ygk commented Jan 6, 2022

That's not that easy, because I do not have old Python versions available. Maybe the non-version-dependent checks should use the default python3 instead of a fixed version.

Depending on your platform, it's fairly easy to have "all the versions" of Python with https://github.com/pyenv/pyenv

I'm pretty sure that tox -e flake8 runs the default python locally. It just needs to be an arbitrary specific Python in the GH workflow.

We really try to make sure all supported version of Python and Django are thoroughly tested, although you can always locally run just tox with the one Python version you have:

(dot-venv) django-oauth-toolkit$ tox -e py39-dj32

Also https://django-oauth-toolkit.readthedocs.io/en/latest/contributing.html documents making sure to install pre-commit which will run pre-commit hooks and catches black, flake8, isort, errors as well as a number of other things (see .pre-commit-config.yaml).

I hope this helps.

@Natureshadow
Copy link
Contributor Author

Natureshadow commented Jan 6, 2022 via email

@n2ygk
Copy link
Member

n2ygk commented Jan 6, 2022

I can't commit to that timeframe, sorry. It's not just about green checkmarks; I need to thoroughly review the code and am busy at my day job too. Last week I had a lot of free time while on vacation.

I am rolling a 1.6.2 hotfix as my first priority to resolve the open issues for those who are experiencing them.

@Natureshadow
Copy link
Contributor Author

Natureshadow commented Jan 6, 2022 via email

@n2ygk
Copy link
Member

n2ygk commented Jan 6, 2022

That would be entirely sufficient, thanks!

Please test with it ASAP and let me know if I got everything.

@n2ygk
Copy link
Member

n2ygk commented Jan 7, 2022

That would be entirely sufficient, thanks!

Please test with it ASAP and let me know if I got everything.

@Natureshadow ^ sorry forgot to tag you in this message. I'm planning on pushing this today.

@Natureshadow
Copy link
Contributor Author

1.6.2 looks good, thanks!

Copy link
Member

@n2ygk n2ygk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been testing this out with this demo app and have come across a small bug. The "sub" is repeated in the claims_supported even when it is not added to the dict of callables in get_additional_claims.

http://localhost:8000/o/.well-known/openid-configuration
    "claims_supported": [
        "sub",
        "sub",
        "first_name",
        "last_name"
    ]

CHANGELOG.md Outdated Show resolved Hide resolved
@n2ygk
Copy link
Member

n2ygk commented Jan 13, 2022

@AndreaGreco @Natureshadow Can you please take a look at #1069 (review)? I'd like to get that bug resolved before proceeding with this PR.

Thanks.

@n2ygk
Copy link
Member

n2ygk commented Jan 22, 2022

@Natureshadow

What can I do to help make it happen?

Please respond to the review requested changes and rebase ASAP as I'd like to push out 1.7.0.

If you don't have time to look at the duplicate "sub" that's OK. I can fix that in a subsequent PR. It's not a huge problem.

If you no longer have time or interest, let me know and I'll finish off this PR.

Also, per a prior discussion in this thread, this repo is configured by the Jazzband roadie(s) to only support squash or rebase commits. That's a Jazzband standard I believe. Merge commits are not configured here, however I believe a rebase commit will record your and @AndreaGreco's authorship if you rebase carefully.

Thanks.

AndreaGreco and others added 4 commits January 23, 2022 00:00
Some client can't use userinfo, and get propelty from claims.
Add claims key inside well-known.
* always propagate request
* have get_additional_claims return a dict again
* allow get_additional_claims to return plain data instead of callables
This splits get_additional_claims into two forms.
See documentation change for rationale.
@Natureshadow Natureshadow force-pushed the claims-discovery-info branch from b3c4a4e to 7befb8b Compare January 22, 2022 23:11
@Natureshadow
Copy link
Contributor Author

Please respond to the review requested changes and rebase ASAP as I'd like to push out 1.7.0.

Done.

Also, per a prior discussion in this thread, this repo is configured by the Jazzband roadie(s) to only support squash or rebase commits. That's a Jazzband standard I believe. Merge commits are not configured here, however I believe a rebase commit will record your and @AndreaGreco's authorship if you rebase carefully.

At least one of us will only be listed in a non-standard, proprietary GitHub pseudo-header. As long as that's not me, I don't care 🤷🏼 .

@n2ygk n2ygk merged commit 9fbe840 into jazzband:master Jan 23, 2022
@Natureshadow Natureshadow deleted the claims-discovery-info branch January 28, 2022 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants