Skip to content

Commit 029ab4a

Browse files
committed
Docs done for now. Releasing v0.1.0.
1 parent 0b37ff7 commit 029ab4a

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed

docs/examples.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Examples
2+
========
3+
4+
The library is pretty thoroughly unit tested. See the ``tests`` folder for those.
5+
6+
Here are very basic examples.
7+
8+
Step 1: Generate a URL::
9+
10+
import sqrlserver
11+
import nacl.utils
12+
13+
key = nacl.utils.random(32)
14+
url = sqrlserver.Url('example.com', 'Example Site')
15+
urlstr = u.generate('/auth/sqrl')
16+
#urlstr = 'sqrl://example.com/auth/sqrl?nut=XXXXX&sfn=RXhhbXBsZSBTaXRl'
17+
18+
Step 2: Receive a Request::
19+
20+
req = Request(key, postparams) #let's assume a basic ``query`` command
21+
assert req.state == 'NEW'
22+
23+
Step 3: Handle the Request::
24+
25+
req.handle()
26+
assert req.state == 'ACTION'
27+
assert req.action == [('find', ['TLpyrowLhWf9-hdLLPQOA-7-xplI9LOxsfLXsyTccVc'])]
28+
29+
req.handle({'found': [True]})
30+
assert req.state == 'COMPLETE'
31+
32+
Step 4: Finalize & Return the Response::
33+
34+
response = req.finalize(counter=101) #will use last URL for 'qry'
35+
#store ``response.hmac(key)`` to the session data
36+
#return ``response.toString()`` to the client

docs/index.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ SQRL Server
1212
:hidden:
1313

1414
usage
15+
examples
1516
divergences
1617
API <modules>
1718

18-
This module supports Python-based web servers in processing `SQRL <https://www.grc.com/sqrl/sqrl.htm>`_ requests. It only does the core protocol work. It leaves data representation, storage, and other platform-specific actions to the server.
19+
This module supports Python-based web servers in processing `SQRL <https://www.grc.com/sqrl/sqrl.htm>`_ requests. It only does the core protocol work (signature validation, etc.). It leaves data representation, storage, and other platform-specific actions to the server.
1920

2021
The following terms are used throughout the documentation:
2122

@@ -43,6 +44,14 @@ For now, download and install manually::
4344
python setup.py test
4445
python setup.py install
4546

47+
Requirements
48+
============
49+
50+
This library only works with Python3. It requires the following external libraries to run:
51+
52+
- bitstring
53+
- PyNaCl
54+
4655
Contribute
4756
==========
4857

@@ -54,6 +63,11 @@ Licence
5463

5564
The project is licensed under the MIT licence.
5665

66+
Changelog
67+
=========
68+
69+
01 Jul 2017
70+
* Initial release (v0.1.0)
5771

5872
Indices and tables
5973
==================

docs/usage.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ The core workflow is quite simple:
99
#. Create a :py:class:`.Url` to generate the URLs that point clients to your SQRL endpoints.
1010
#. Create a :py:class:`.Request` object when a POST is made to those endpoints.
1111
#. Call the request's :py:meth:`.Request.handle` method repeatedly until its ``state`` is ``COMPLETE``.
12-
#. Call :py:meth:`.Request.finalize` to get a :py:class:`.Response` object.
13-
#. Return :py:meth:`.Response.toString` to the client.
12+
#. Call :py:meth:`.Request.finalize` to get a :py:class:`.Response` object and then return :py:meth:`.Response.toString` to the client.
1413

1514
Step 1: Generate a URL
1615
----------------------
@@ -353,17 +352,14 @@ encrypted values.
353352

354353
The value must be a string.
355354

356-
Step 4: Finalize the Request
357-
----------------------------
355+
Step 4: Finalize & Return the Response
356+
--------------------------------------
358357

359358
The :py:meth:`.Request.finalize` method does the final steps to prepare the :py:class:`.Response`. You must pass it either a :py:class:`.Nut` you manually generated or the data needed to autogenerate a new one for you. It also finalizes the URL you want the client to respond to with its next request.
360359

361360
This method does not affect the :py:class:`.Request` object in any way. You can safely call this method multiple times with different parameters.
362361

363-
it will return to you a valid :py:class:`.Response` object.
364-
365-
Step 5: Return the Response
366-
---------------------------
362+
It will return to you a valid :py:class:`.Response` object.
367363

368364
At this point it's a simple matter of calling :py:meth:`.Response.toString` and returning that in the body of your response to the client's POST.
369365

0 commit comments

Comments
 (0)