Revision 462c63e8 docs/source/devguide.rst

b/docs/source/devguide.rst
4 4
Introduction
5 5
------------
6 6

  
7
Astakos is a identity management service implemented by GRNET (http://www.grnet.gr). Users can create and manage their account, invite others and send feedback for GRNET services. During the account creation the user can select against which provider wants to authenticate:
7
Astakos serves as the point of authentication for GRNET (http://www.grnet.gr) services. It is a platform-wide service, allowing users to register, login, and keep track of permissions.
8 8

  
9
* Astakos
9
Users in astakos can be authenticated via several identity providers:
10

  
11
* Local
10 12
* Twitter
11 13
* Shibboleth
12 14

  
13
Astakos provides also an administrative interface for managing user accounts.
15
It provides also an administrative interface for managing user accounts.
14 16

  
15
Astakos is build over django and extends its authentication mechanism.
17
It is build over django and extends its authentication mechanism.
16 18

  
17 19
This document's goals are:
18 20

  
19
* Define the Astakos ReST API that allows the GRNET services to retrieve user information via HTTP calls
20
* Describe the Astakos views and provide guidelines for a developer to extend them
21
* present the overall architectural design.
22
* provide basic use cases.
23
* describe the APIs to the outer world.
24
* document the views and provide guidelines for a developer to extend them.
21 25

  
22
The present document is meant to be read alongside the Django documentation. Thus, it is suggested that the reader is familiar with associated technologies.
26
The present document is meant to be read alongside the Django documentation (https://www.djangoproject.com/). Thus, it is suggested that the reader is familiar with associated technologies.
23 27

  
24 28
Document Revisions
25 29
^^^^^^^^^^^^^^^^^^
......
30 34
0.1 (Jub 24, 2012)         Initial release.
31 35
=========================  ================================
32 36

  
37
Overview
38
--------
39

  
40
Astakos service co-ordinates the access to resources (and the subsequent permission model) and acts as the single point of registry and entry to the GRNET cloud offering, comprising of Cyclades and Pithos subsystems.
41

  
42
It also propagates the user state to the Aquarium pricing subsystem.
43

  
44
.. image:: images/~okeanos.jpg
45

  
46
Registration Use Cases
47
----------------------
48

  
49
The following subsections describe two basic registration use cases. All the registration cases are covered in :ref:`registration-flow-label`
50

  
51
Invited user
52
^^^^^^^^^^^^
53

  
54
A registered ~okeanos user, invites student Alice to subscribe to ~okeanos services. Alice receives an email and through a link is navigated to Astakos's signup page. The system prompts her to select one of the available authentication mechanisms (Shibboleth, Twitter or local authentication) in order to register to the system. Alice already has a Shibboleth account so chooses that and then she is redirected to her institution's login page. Upon successful login, her account is created.
55

  
56
Since she is invited his account is automaticaly activated and she is redirected to Astakos's login page. As this is the first time Alice has accessed the system she is redirected to her profile page where she can edit or provide more information.
57

  
58
Not invited user
59
^^^^^^^^^^^^^^^^
60

  
61
Tony while browsing in the internet finds out about ~okeanos services. He visits the signup page and since his has already a twitter account selects the twitter authentication mechanism and he is redirected to twitter login page where he is promted to provide his credentials. Upon successful login, twitter redirects him back to the Astakos and the account is created.
62

  
63
Since his not an invited user his account has to be activated from an administrator first, in order to be able to login. Upon the account's activation he receives an email and through a link he is redirected to the login page.
64

  
65
Authentication Use Cases
66
------------------------
67

  
68
Cloud service user
69
^^^^^^^^^^^^^^^^^^
70

  
71
Alice requests a specific resource from a cloud service ex. Pithos. In the request supplies the `X-Auth-Token`` to identify whether she is eligible to perform the specific task. The service contacts Astakos through its ``/im/authenticate`` api call (see :ref:`authenticate-api-label`) providing the specific ``X-Auth-Token``. Astakos checkes whether the token belongs to an active user and it has not expired and returns a dictionary containing user related information. Finally the service uses the ``uniq`` field included in the dictionary as the account string to identify the user accessible resources. 
72

  
73
.. _registration-flow-label:
74

  
75
Registration Flow
76
-----------------
77

  
78
.. image:: images/signup.jpg
79
    :scale: 150%
80

  
81
Login Flow
82
----------
83
.. image:: images/login.jpg
84
    :scale: 150%
85

  
86
.. _authentication-label:
87

  
33 88
Astakos Users and Authentication
34 89
--------------------------------
35 90

  
36
Astakos extends django User model.
91
Astakos incorporates django user authentication system and extends its User model.
37 92

  
38
Each user is uniquely identified by the ``username`` field. An astakos user instance is assigned also with a ``auth_token`` field used by the astakos clients to authenticate a user. All API requests require a token.
93
Since username field of django User model has a limitation of 30 characters, AstakosUser is **uniquely** identified by the ``email`` instead. Therefore, ``astakos.im.authentication_backends.EmailBackend`` is served to authenticate a user using email if the first argument is actually an email, otherwise tries the username.
94

  
95
A new AstakosUser instance is assigned with a uui as username and also with a ``auth_token`` used by the cloud services to authenticate the user. ``astakos.im.authentication_backends.TokenBackend`` is also specified in order to authenticate the user using the email and the token fields.
39 96

  
40 97
Logged on users can perform a number of actions:
41 98

  
42
* access and edit their profile via: ``https://hostname/im/profile``.
43
* change their password via: ``https://hostname/im/password``
44
* invite somebody else via: ``https://hostname/im/invite``
45
* send feedback for grnet services via: ``https://hostname/im/send_feedback``
46
* logout via: ``https://hostname/im/logout``
99
* access and edit their profile via: ``/im/profile``.
100
* change their password via: ``/im/password``
101
* invite somebody else via: ``/im/invite``
102
* send feedback for grnet services via: ``/im/send_feedback``
103
* logout (and delete cookie) via: ``/im/logout``
104

  
105
User entries can also be modified/added via the administrative interface available at ``/im/admin``.
47 106

  
48
User entries can also be modified/added via the management interface available at ``https://hostname/im/admin``.
107
A superuser account can be created the first time you run the ``manage.py syncdb`` django command. At a later date, the ``manage.py createsuperuser`` command line utility can be used.
49 108

  
50
A superuser account can be created the first time you run the manage.py syncdb django command. At a later date, the manage.py createsuperuser command line utility can be used.
109
Internal Astakos requests are handled using cookie-based django user sessions.
51 110

  
52
Astakos is also compatible with Twitter and Shibboleth (http://shibboleth.internet2.edu/). The connection between Twitter and Astakos is done by ``https://hostname/im/target/twitter/login``. The connection between Shibboleth and Astakos is done by ``https://hostname/im/target/shibboleth/login``. An application that wishes to connect to Astakos, but does not have a token, should redirect the user to ``https://hostname/im/login``.
111
External systems in the same domain can delgate ``/login`` URI. The server, depending on its configuration will redirect to the appropriate login page. When done with logging in, the service's login URI should redirect to the URI provided with next, adding user and token parameters, which contain the email and token fields respectively.
53 112

  
54 113
The login URI accepts the following parameters:
55 114

  
......
60 119
renew                   Force token renewal (no value parameter)
61 120
======================  =========================
62 121

  
63
In case the user wants to authenticate via Astakos fills the login form and post it to ``https://hostname/im/local/login``.
122
External systems outside the domain scope can acquire the user information by a cookie set identified by ASTAKOS_COOKIE_NAME setting.
64 123

  
65
Otherwise (the user selects a third party authentication) the login process starts by redirecting the user to an external URI (controlled by the third party), where the actual authentication credentials are entered. Then, the user is redirected back to the login URI, with various identification information in the request headers.
66

  
67
If the user does not exist in the database, Astakos adds the user and creates a random token. If the user exists, the token has not expired and ``renew`` is not set, the existing token is reused. Finally, the login URI redirects to the URI provided with ``next``, adding the ``user`` and ``token`` parameters, which contain the ``Uniq`` and ``Token`` fields respectively.
124
Finally, backend systems having acquired a token can use the :ref:`authenticate-api-label` api call from a private network or through HTTPS.
68 125

  
69 126
The Astakos API
70 127
---------------
71 128

  
129
All API requests require a token. An application that wishes to connect to Astakos, but does not have a token, should redirect the user to ``/login``. (see :ref:`authentication-label`)
130

  
131
.. _authenticate-api-label:
132

  
72 133
Authenticate
73 134
^^^^^^^^^^^^
74 135

  
75
==================================== =========  ==================
136
==================== =========  ==================
76 137
Uri                                  Method     Description
77
==================================== =========  ==================
78
``https://hostname/im/authenticate`` GET        Authenticate user using token
79
==================================== =========  ==================
138
==================== =========  ==================
139
``/im/authenticate`` GET        Authenticate user using token
140
==================== =========  ==================
80 141

  
81 142
|
82 143

  
......
91 152
===========================  ============================
92 153
Name                         Description
93 154
===========================  ============================
94
uniq                         User uniq identifier
155
username                     User uniq identifier
156
uniq                         User email (uniq identifier used by Astakos)
95 157
auth_token                   Authentication token
96 158
auth_token_expires           Token expiration date
97 159
auth_token_created           Token creation date
......
101 163

  
102 164
::
103 165

  
104
  {"uniq": "admin",
166
  {"username": "4ad9f34d6e7a4992b34502d40f40cb",
167
  "uniq": "papagian@example.com"
105 168
  "auth_token": "0000",
106 169
  "auth_token_expires": "Tue, 11-Sep-2012 09:17:14 ",
107 170
  "auth_token_created": "Sun, 11-Sep-2011 09:17:14 "}

Also available in: Unified diff