Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
c5bc98d7
Kaydet (Commit)
c5bc98d7
authored
Tem 03, 2013
tarafından
Tomáš Ehrlich
Kaydeden (comit)
Tim Graham
Tem 03, 2013
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #20687 -- Added documentation for django.core.signing API.
Thanks Baptiste Mispelon for the suggestion.
üst
63b21559
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
signing.py
django/core/signing.py
+4
-0
signing.txt
docs/topics/signing.txt
+20
-6
No files found.
django/core/signing.py
Dosyayı görüntüle @
c5bc98d7
...
@@ -183,6 +183,10 @@ class TimestampSigner(Signer):
...
@@ -183,6 +183,10 @@ class TimestampSigner(Signer):
return
super
(
TimestampSigner
,
self
)
.
sign
(
value
)
return
super
(
TimestampSigner
,
self
)
.
sign
(
value
)
def
unsign
(
self
,
value
,
max_age
=
None
):
def
unsign
(
self
,
value
,
max_age
=
None
):
"""
Retrieve original value and check it wasn't signed more
than max_age seconds ago.
"""
result
=
super
(
TimestampSigner
,
self
)
.
unsign
(
value
)
result
=
super
(
TimestampSigner
,
self
)
.
unsign
(
value
)
value
,
timestamp
=
result
.
rsplit
(
self
.
sep
,
1
)
value
,
timestamp
=
result
.
rsplit
(
self
.
sep
,
1
)
timestamp
=
baseconv
.
base62
.
decode
(
timestamp
)
timestamp
=
baseconv
.
base62
.
decode
(
timestamp
)
...
...
docs/topics/signing.txt
Dosyayı görüntüle @
c5bc98d7
...
@@ -37,8 +37,6 @@ generate their own signed values.
...
@@ -37,8 +37,6 @@ generate their own signed values.
Using the low-level API
Using the low-level API
=======================
=======================
.. class:: Signer
Django's signing methods live in the ``django.core.signing`` module.
Django's signing methods live in the ``django.core.signing`` module.
To sign a value, first instantiate a ``Signer`` instance::
To sign a value, first instantiate a ``Signer`` instance::
...
@@ -74,6 +72,11 @@ generate signatures. You can use a different secret by passing it to the
...
@@ -74,6 +72,11 @@ generate signatures. You can use a different secret by passing it to the
>>> value
>>> value
'My string:EkfQJafvGyiofrdGnuthdxImIJw'
'My string:EkfQJafvGyiofrdGnuthdxImIJw'
.. class:: Signer(key=None, sep=':', salt=None)
Returns a signer which uses ``key`` to generate signatures and ``sep``
to separate values.
Using the salt argument
Using the salt argument
-----------------------
-----------------------
...
@@ -105,8 +108,6 @@ secret.
...
@@ -105,8 +108,6 @@ secret.
Verifying timestamped values
Verifying timestamped values
----------------------------
----------------------------
.. class:: TimestampSigner
``TimestampSigner`` is a subclass of :class:`~Signer` that appends a signed
``TimestampSigner`` is a subclass of :class:`~Signer` that appends a signed
timestamp to the value. This allows you to confirm that a signed value was
timestamp to the value. This allows you to confirm that a signed value was
created within a specified period of time::
created within a specified period of time::
...
@@ -124,6 +125,17 @@ created within a specified period of time::
...
@@ -124,6 +125,17 @@ created within a specified period of time::
>>> signer.unsign(value, max_age=20)
>>> signer.unsign(value, max_age=20)
u'hello'
u'hello'
.. class:: TimestampSigner(key=None, sep=':', salt=None)
.. method:: sign(value)
Sign ``value`` and append current timestamp to it.
.. method:: unsign(value, max_age=None)
Checks if ``value`` was signed less than ``max_age`` seconds ago,
otherwise raises ``SignatureExpired``.
Protecting complex data structures
Protecting complex data structures
----------------------------------
----------------------------------
...
@@ -142,8 +154,10 @@ to execute arbitrary commands by exploiting the pickle format.::
...
@@ -142,8 +154,10 @@ to execute arbitrary commands by exploiting the pickle format.::
.. function:: dumps(obj, key=None, salt='django.core.signing', compress=False)
.. function:: dumps(obj, key=None, salt='django.core.signing', compress=False)
Returns URL-safe, sha1 signed base64 compressed JSON string.
Returns URL-safe, sha1 signed base64 compressed JSON string. Serialized
object is signed using :class:`~TimestampSigner`.
.. function:: loads(string, key=None, salt='django.core.signing', max_age=None)
.. function:: loads(string, key=None, salt='django.core.signing', max_age=None)
Reverse of dumps(), raises ``BadSignature`` if signature fails.
Reverse of ``dumps()``, raises ``BadSignature`` if signature fails.
Checks ``max_age`` (in seconds) if given.
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