Skip to content

Commit b2840cc

Browse files
authored
Merge branch 'master' into css_do_over_2
2 parents 1f89e9d + 4e0bdf1 commit b2840cc

4 files changed

Lines changed: 10 additions & 12 deletions

File tree

src/bornhack/oauth_validators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class BornhackOAuth2Validator(OAuth2Validator):
1010
# https://django-oauth-toolkit.readthedocs.io/en/latest/oidc.html#using-oidc-scopes-to-determine-which-claims-are-returned
1111
oidc_claim_scope = {
1212
# the OIDC standard user claims we support, and the OIDC standard scopes they require
13+
"sub": "openid",
1314
"email": "email",
1415
"email_verified": "email",
1516
"phone_number": "phone",

src/profiles/forms.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44

55
def get_scopes() -> list[str]:
66
validator = BornhackOAuth2Validator()
7-
return (
8-
(claim, claim) for claim in sorted(set(validator.oidc_claim_scope.values()))
9-
)
10-
7+
return ((scope, scope) for scope in sorted(set(validator.oidc_claim_scope.values())) if scope!="openid")
118

9+
1210
class OIDCForm(forms.Form):
1311
scopes = forms.MultipleChoiceField(
1412
choices=get_scopes,
15-
help_text="Select the scopes to simulate",
16-
)
13+
help_text="Select the scopes to simulate. The 'openid' scope is always included.",
14+
)

src/profiles/templates/oidc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<h4>OIDC Claims</h4>
1212
</div>
1313
<div class="card-body">
14-
<p class="lead">When using BornHack as an IDP (logging into other sites using your BornHack account) you can control which user claims are returned by asking for one or more of the following claim scopes:</p>
14+
<p class="lead">When using BornHack as an IDP (logging into other sites using your BornHack account) you can control which <i>user claims</i> are shared with the remote site by asking for one or more of the following <i>claim scopes</i>:</p>
1515
<p><ul>
1616
{% for scope in all_scopes %}
1717
<li><code>{{ scope }}</code></li>

src/profiles/views.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ def get_context_data(self, **kwargs):
155155
if scope in self.request.GET.getlist(key="scopes"):
156156
context["claims"][claim] = value
157157
context["scopes"] = self.scopes
158-
context["active_scopes"] = ["openid"] + sorted(
159-
list(set(self.request.GET.getlist(key="scopes")))
160-
)
161-
context["all_scopes"] = sorted(list(set(self.scopes.values())))
162-
return context
158+
context["active_scopes"] = ["openid"] + sorted(set(self.request.GET.getlist(key="scopes")))
159+
context["all_scopes"] = sorted(set(self.scopes.values()))
160+
del(context["all_scopes"][context["all_scopes"].index("openid")])
161+
return context

0 commit comments

Comments
 (0)