Statistics
| Branch: | Tag: | Revision:

root / docs / source / devguide.rst @ 270dd48d

History | View | Annotate | Download (10.2 kB)

1
Astakos Developer Guide
2
=======================
3

    
4
Introduction
5
------------
6

    
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

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

    
11
* Local
12
* Twitter
13
* Shibboleth
14

    
15
It provides also a command line tool for managing user accounts.
16

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

    
19
This document's goals are:
20

    
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.
25

    
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.
27

    
28
Document Revisions
29
^^^^^^^^^^^^^^^^^^
30

    
31
=========================  ================================
32
Revision                   Description
33
=========================  ================================
34
0.1 (Feb 10, 2012)         Initial release.
35
=========================  ================================
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: 100%
80

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

    
86
.. _authentication-label:
87

    
88
Astakos Users and Authentication
89
--------------------------------
90

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

    
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.
96

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

    
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 ``snf-manage activateuser`` command.
106

    
107
A superuser account can be created the first time you run the ``manage.py syncdb`` django command and then loading the extra user data from the ``admin_user`` fixture. At a later date, the ``manage.py createsuperuser`` command line utility can be used (as long as the extra user data for Astakos is added with a fixture or by hand).
108

    
109
Internal Astakos requests are handled using cookie-based django user sessions.
110

    
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.
112

    
113
The login URI accepts the following parameters:
114

    
115
======================  =========================
116
Request Parameter Name  Value
117
======================  =========================
118
next                    The URI to redirect to when the process is finished
119
renew                   Force token renewal (no value parameter)
120
force                   Force logout current user (no value parameter)
121
======================  =========================
122

    
123
External systems outside the domain scope can acquire the user information by a cookie set identified by ASTAKOS_COOKIE_NAME setting.
124

    
125
Finally, backend systems having acquired a token can use the :ref:`authenticate-api-label` api call from a private network or through HTTPS.
126

    
127
The Astakos API
128
---------------
129

    
130
.. _authenticate-api-label:
131

    
132
Authenticate
133
^^^^^^^^^^^^
134

    
135
Authenticate 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`)
136

    
137
==================== =========  ==================
138
Uri                  Method     Description
139
==================== =========  ==================
140
``/im/authenticate`` GET        Authenticate user using token
141
==================== =========  ==================
142

    
143
|
144

    
145
====================  ===========================
146
Request Header Name   Value
147
====================  ===========================
148
X-Auth-Token          Authentication token
149
====================  ===========================
150

    
151
Extended information on the user serialized in the json format will be returned:
152

    
153
===========================  ============================
154
Name                         Description
155
===========================  ============================
156
username                     User uniq identifier
157
uniq                         User email (uniq identifier used by Astakos)
158
auth_token                   Authentication token
159
auth_token_expires           Token expiration date
160
auth_token_created           Token creation date
161
has_credits                  Whether user has credits
162
has_signed_terms             Whether user has aggred on terms
163
===========================  ============================
164

    
165
Example reply:
166

    
167
::
168

    
169
  {"username": "4ad9f34d6e7a4992b34502d40f40cb",
170
  "uniq": "papagian@example.com"
171
  "auth_token": "0000",
172
  "auth_token_expires": "Tue, 11-Sep-2012 09:17:14 ",
173
  "auth_token_created": "Sun, 11-Sep-2011 09:17:14 ",
174
  "has_credits": false,
175
  "has_signed_terms": true}
176

    
177
|
178

    
179
=========================== =====================
180
Return Code                 Description
181
=========================== =====================
182
204 (No Content)            The request succeeded
183
400 (Bad Request)           The request is invalid
184
401 (Unauthorized)          Missing token or inactive user or penging approval terms
185
500 (Internal Server Error) The request cannot be completed because of an internal error
186
=========================== =====================
187

    
188
Get Services
189
^^^^^^^^^^^^
190

    
191
Returns a json formatted list containing information about the supported cloud services.
192

    
193
==================== =========  ==================
194
Uri                  Method     Description
195
==================== =========  ==================
196
``/im/get_services`` GET        Get cloud services
197
==================== =========  ==================
198

    
199
Example reply:
200

    
201
::
202

    
203
[{"url": "/", "icon": "home-icon.png", "name": "grnet cloud", "id": "cloud"},
204
 {"url": "/okeanos.html", "name": "~okeanos", "id": "okeanos"},
205
 {"url": "/ui/", "name": "pithos+", "id": "pithos"}]
206
 
207
Get Menu
208
^^^^^^^^
209

    
210
Returns a json formatted list containing the cloud bar links. 
211

    
212
==================== =========  ==================
213
Uri                  Method     Description
214
==================== =========  ==================
215
``/im/get_menu``     GET        Get cloud bar menu
216
==================== =========  ==================
217

    
218
|
219

    
220
======================  =========================
221
Request Parameter Name  Value
222
======================  =========================
223
location                Location to pass in the next parameter
224
======================  =========================
225

    
226
Example reply if request user is not authenticated:
227

    
228
::
229

    
230
[{"url": "/im/login?next=", "name": "login..."}]
231

    
232
Example reply if request user is authenticated:
233

    
234
[{"url": "/im/profile", "name": "spapagian@grnet.gr"},
235
 {"url": "/im/profile", "name": "view your profile..."},
236
 {"url": "/im/password", "name": "change your password..."},
237
 {"url": "/im/feedback", "name": "feedback..."},
238
 {"url": "/im/logout", "name": "logout..."}]
239

    
240

    
241

    
242