-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.html
executable file
·134 lines (133 loc) · 3.19 KB
/
doc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/style.css" />
<title>Hack In TN - Documentation</title>
<meta charset="utf-8" />
<style>
table {
clear: left;
border-collapse: collapse;
text-align: left;
width: 98%;
margin-left: 1%;
border-radius: 15px;
}
table, tr, td {
border: 1px dashed #995;
}
th {
border-bottom: 1px solid #995;
}
tr:nth-child(even) {
background-color: rgba(0, 0, 0, 0.1);
}
tr:nth-child(odd) {
background-color: rgba(0, 0, 0, 0);
}
</style>
</head>
<body>
<div id="title" ><h1>Hack In TN - Documentation</h1></div>
<div id="main">
<h3>Documentation de l'API</h3>
<div class="exContainer">
<h4>API Docker</h4>
<p>
L'api est disponible à l'adresse :<br />
<a href="/api">hackintn.telecomnancy.net/api/</a>
</p>
</div>
<div class="exContainer">
<h4>Tokens</h4>
<p>
L'utilisateur s'identifie auprès de l'API en utilisant un système de tokens.<br />
Pour cela, l'utilisateur demande un token unique [T0], valable 12 heures, à l'url <code>/api/token</code>.<br />
Puis, l'utilisateur hash la chaîne :<br />
<code>path//json</code><br />
à l'aide de l'algorithme <code>bcrypt</code>, en utilisant son token [T0] comme sel, pour obtenir un token [T1]<br />
<small>Note : le JSON doit contenir le champ <code>token_date</code>, donnant le timestamp de la requête.</small><br />
Enfin, L'utilisateur joint à son JSON le champ <code>token</code> contenant le token [T1].<br />
L'user_id de la demande est assumé par l'URL, sauf s'il est précisé par un champ <code>user_id</code> dans le JSON de la requête.
</p>
</div>
<table>
<tr>
<th>METHODE</th>
<th>ROUTE</th>
<th>EFFET</th>
<th>ARGUMENTS</th>
<th>RETOUR</th>
</tr>
<tr>
<td><pre>GET</pre></td>
<td><pre>/api/user</pre></td>
<td>Affiche une liste d'utilisateurs</td>
<td><pre>{
begin: <int>,
length: <int>
}</pre></td>
<td><pre>{
begin: <int>,
length: <int>,
users: [{
id: <int>,
email: <string>
username: <string>
}]
}</pre></td>
</tr>
<tr>
<td><pre>POST</pre></td>
<td><pre>/api/user</pre></td>
<td>Créé un utilisateur</td>
<td><pre>{
username: <string>,
password: <string>,
email: <string>
}</pre></td>
<td><pre>{
user: {
id: <int>,
email: <string>
username: <string>
}
}</pre></td>
</tr>
<tr>
<td><pre>GET</pre></td>
<td><pre>/api/user/<int:user_id></pre></td>
<td>Récupère les données d'un utilisateur</td>
<td><pre>None</pre></td>
<td><pre>{
user: {
id: <int>,
email: <string>
username: <string>
}
}</pre></td>
</tr>
<tr>
<td><pre>DELETE</pre></td>
<td><pre>/api/user/<int:user_id></pre></td>
<td>Supprime l'utilisateur</td>
<td><pre>{
[user_id: <int>,]
token_date: <date>,
token: <token>
}</pre></td>
<td><pre>{
user: {
id: <int>,
email: <string>
username: <string>
}
}</pre></td>
</tr>
</table>
</div>
<div id="footer">
©Telecom Nancy 2015-2015 - <a href="credits.html">Credits</a>
</div>
</body>
</html>