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
3c2afa27
Commit
3c2afa27
authored
May 27, 2009
by
James Henstridge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make changes to store implementation in response to the review of the
Storm based OpenID store I wrote based on this one.
parent
8f12fc67
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
10 deletions
+34
-10
django_openid_auth/store.py
+16
-7
django_openid_auth/tests/test_store.py
+18
-3
No files found.
django_openid_auth/store.py
View file @
3c2afa27
...
...
@@ -42,13 +42,22 @@ class DjangoOpenIDStore(OpenIDStore):
self
.
max_nonce_age
=
6
*
60
*
60
# Six hours
def
storeAssociation
(
self
,
server_url
,
association
):
assoc
=
Association
(
server_url
=
server_url
,
handle
=
association
.
handle
,
secret
=
base64
.
encodestring
(
association
.
secret
),
issued
=
association
.
issued
,
lifetime
=
association
.
lifetime
,
assoc_type
=
association
.
assoc_type
)
try
:
assoc
=
Association
.
objects
.
get
(
server_url
=
server_url
,
handle
=
association
.
handle
)
except
Association
.
DoesNotExist
:
assoc
=
Association
(
server_url
=
server_url
,
handle
=
association
.
handle
,
secret
=
base64
.
encodestring
(
association
.
secret
),
issued
=
association
.
issued
,
lifetime
=
association
.
lifetime
,
assoc_type
=
association
.
assoc_type
)
else
:
assoc
.
secret
=
base64
.
encodestring
(
association
.
secret
)
assoc
.
issued
=
association
.
issued
assoc
.
lifetime
=
association
.
lifetime
assoc
.
assoc_type
=
association
.
assoc_type
assoc
.
save
()
def
getAssociation
(
self
,
server_url
,
handle
=
None
):
...
...
django_openid_auth/tests/test_store.py
View file @
3c2afa27
...
...
@@ -56,6 +56,20 @@ class OpenIDStoreTests(TestCase):
self
.
assertEquals
(
dbassoc
.
lifetime
,
600
)
self
.
assertEquals
(
dbassoc
.
assoc_type
,
'HMAC-SHA1'
)
def
test_storeAssociation_update_existing
(
self
):
assoc
=
OIDAssociation
(
'handle'
,
'secret'
,
42
,
600
,
'HMAC-SHA1'
)
self
.
store
.
storeAssociation
(
'server-url'
,
assoc
)
# Now update the association with new information.
assoc
=
OIDAssociation
(
'handle'
,
'secret2'
,
420
,
900
,
'HMAC-SHA256'
)
self
.
store
.
storeAssociation
(
'server-url'
,
assoc
)
dbassoc
=
Association
.
objects
.
get
(
server_url
=
'server-url'
,
handle
=
'handle'
)
self
.
assertEqual
(
dbassoc
.
secret
,
'secret2'
.
encode
(
'base-64'
))
self
.
assertEqual
(
dbassoc
.
issued
,
420
)
self
.
assertEqual
(
dbassoc
.
lifetime
,
900
)
self
.
assertEqual
(
dbassoc
.
assoc_type
,
'HMAC-SHA256'
)
def
test_getAssociation
(
self
):
timestamp
=
int
(
time
.
time
())
self
.
store
.
storeAssociation
(
...
...
@@ -104,9 +118,6 @@ class OpenIDStoreTests(TestCase):
self
.
assertEquals
(
assoc
.
issued
,
timestamp
+
1
)
def
test_removeAssociation
(
self
):
self
.
assertEquals
(
self
.
store
.
removeAssociation
(
'server-url'
,
'unknown'
),
False
)
timestamp
=
int
(
time
.
time
())
self
.
store
.
storeAssociation
(
'server-url'
,
OIDAssociation
(
'handle'
,
'secret'
,
timestamp
,
600
,
...
...
@@ -116,6 +127,10 @@ class OpenIDStoreTests(TestCase):
self
.
assertEquals
(
self
.
store
.
getAssociation
(
'server-url'
,
'handle'
),
None
)
def
test_removeAssociation_unknown
(
self
):
self
.
assertEquals
(
self
.
store
.
removeAssociation
(
'server-url'
,
'unknown'
),
False
)
def
test_useNonce
(
self
):
timestamp
=
time
.
time
()
# The nonce can only be used once.
...
...
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