Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-openid-auth
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-openid-auth
Commits
be4ab878
Commit
be4ab878
authored
Jun 18, 2013
by
Ricardo Kirkner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only request account_verified if there are valid schemes registered for the endpoint
parent
8e831f3b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
+26
-8
django_openid_auth/tests/test_views.py
+10
-3
django_openid_auth/views.py
+16
-5
No files found.
django_openid_auth/tests/test_views.py
View file @
be4ab878
...
@@ -1164,7 +1164,8 @@ class RelyingPartyTests(TestCase):
...
@@ -1164,7 +1164,8 @@ class RelyingPartyTests(TestCase):
self
.
assertEqual
([
'email'
,
'language'
],
sreg_request
.
required
)
self
.
assertEqual
([
'email'
,
'language'
],
sreg_request
.
required
)
self
.
assertEqual
([
'fullname'
,
'nickname'
],
sreg_request
.
optional
)
self
.
assertEqual
([
'fullname'
,
'nickname'
],
sreg_request
.
optional
)
def
check_login_attribute_exchange
(
self
,
validation_type
,
is_verified
):
def
check_login_attribute_exchange
(
self
,
validation_type
,
is_verified
,
request_account_verified
=
True
):
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
settings
.
OPENID_UPDATE_DETAILS_FROM_SREG
=
True
user
=
User
.
objects
.
create_user
(
'testuser'
,
'someone@example.com'
)
user
=
User
.
objects
.
create_user
(
'testuser'
,
'someone@example.com'
)
useropenid
=
UserOpenID
(
useropenid
=
UserOpenID
(
...
@@ -1208,8 +1209,10 @@ class RelyingPartyTests(TestCase):
...
@@ -1208,8 +1209,10 @@ class RelyingPartyTests(TestCase):
self
.
assertTrue
(
fetch_request
.
has_key
(
self
.
assertTrue
(
fetch_request
.
has_key
(
'http://schema.openid.net/namePerson/friendly'
))
'http://schema.openid.net/namePerson/friendly'
))
# Account verification:
# Account verification:
self
.
assertTrue
(
fetch_request
.
has_key
(
self
.
assertEqual
(
'http://ns.login.ubuntu.com/2013/validation/account'
))
fetch_request
.
has_key
(
'http://ns.login.ubuntu.com/2013/validation/account'
),
request_account_verified
)
# Build up a response including AX data.
# Build up a response including AX data.
openid_response
=
openid_request
.
answer
(
True
)
openid_response
=
openid_request
.
answer
(
True
)
...
@@ -1261,6 +1264,10 @@ class RelyingPartyTests(TestCase):
...
@@ -1261,6 +1264,10 @@ class RelyingPartyTests(TestCase):
}
}
self
.
check_login_attribute_exchange
(
None
,
is_verified
=
False
)
self
.
check_login_attribute_exchange
(
None
,
is_verified
=
False
)
def
test_login_attribute_exchange_without_account_verified
(
self
):
self
.
check_login_attribute_exchange
(
None
,
is_verified
=
False
,
request_account_verified
=
False
)
def
test_login_attribute_exchange_unrecognised_validation
(
self
):
def
test_login_attribute_exchange_unrecognised_validation
(
self
):
settings
.
OPENID_VALID_VERIFICATION_SCHEMES
=
{
settings
.
OPENID_VALID_VERIFICATION_SCHEMES
=
{
self
.
provider
.
endpoint_url
:
(
'token_via_email'
,),
self
.
provider
.
endpoint_url
:
(
'token_via_email'
,),
...
...
django_openid_auth/views.py
View file @
be4ab878
...
@@ -169,7 +169,6 @@ def login_begin(request, template_name='openid/login.html',
...
@@ -169,7 +169,6 @@ def login_begin(request, template_name='openid/login.html',
redirect_field_name
:
redirect_to
redirect_field_name
:
redirect_to
},
context_instance
=
RequestContext
(
request
))
},
context_instance
=
RequestContext
(
request
))
error
=
None
consumer
=
make_consumer
(
request
)
consumer
=
make_consumer
(
request
)
try
:
try
:
openid_request
=
consumer
.
begin
(
openid_url
)
openid_request
=
consumer
.
begin
(
openid_url
)
...
@@ -180,7 +179,8 @@ def login_begin(request, template_name='openid/login.html',
...
@@ -180,7 +179,8 @@ def login_begin(request, template_name='openid/login.html',
# Request some user details. If the provider advertises support
# Request some user details. If the provider advertises support
# for attribute exchange, use that.
# for attribute exchange, use that.
if
openid_request
.
endpoint
.
supportsType
(
ax
.
AXMessage
.
ns_uri
):
endpoint
=
openid_request
.
endpoint
if
endpoint
.
supportsType
(
ax
.
AXMessage
.
ns_uri
):
fetch_request
=
ax
.
FetchRequest
()
fetch_request
=
ax
.
FetchRequest
()
# We mark all the attributes as required, since Google ignores
# We mark all the attributes as required, since Google ignores
# optional attributes. We request both the full name and
# optional attributes. We request both the full name and
...
@@ -198,10 +198,21 @@ def login_begin(request, template_name='openid/login.html',
...
@@ -198,10 +198,21 @@ def login_begin(request, template_name='openid/login.html',
(
'http://schema.openid.net/contact/email'
,
'old_email'
),
(
'http://schema.openid.net/contact/email'
,
'old_email'
),
(
'http://schema.openid.net/namePerson'
,
'old_fullname'
),
(
'http://schema.openid.net/namePerson'
,
'old_fullname'
),
(
'http://schema.openid.net/namePerson/friendly'
,
(
'http://schema.openid.net/namePerson/friendly'
,
'old_nickname'
),
'old_nickname'
)]:
(
'http://ns.login.ubuntu.com/2013/validation/account'
,
'account_verified'
)]:
fetch_request
.
add
(
ax
.
AttrInfo
(
attr
,
alias
=
alias
,
required
=
True
))
fetch_request
.
add
(
ax
.
AttrInfo
(
attr
,
alias
=
alias
,
required
=
True
))
# conditionally require account_verified attribute
verification_scheme_map
=
getattr
(
settings
,
'OPENID_VALID_VERIFICATION_SCHEMES'
,
{})
valid_schemes
=
verification_scheme_map
.
get
(
endpoint
.
server_url
,
verification_scheme_map
.
get
(
None
,
()))
if
valid_schemes
:
# there are valid schemes configured for this endpoint, so
# request account_verified status
fetch_request
.
add
(
ax
.
AttrInfo
(
'http://ns.login.ubuntu.com/2013/validation/account'
,
alias
=
'account_verified'
,
required
=
True
))
openid_request
.
addExtension
(
fetch_request
)
openid_request
.
addExtension
(
fetch_request
)
else
:
else
:
sreg_required_fields
=
[]
sreg_required_fields
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment