@@ -10,12 +10,12 @@ This document provides protocol-level details of the SensorWeb API.
1010
1111All requests will be to URLs of the form:
1212
13- https://<host-url>/api/v1 /<api-endpoint>
13+ https://<host-url>/< api-version> /<api-endpoint>
1414
1515Note that:
1616
1717* All API access must be over a properly-validated HTTPS connection.
18- * The URL embeds a version identifier "v1"; future revisions of this API may
18+ * The URL embeds a version identifier "v1.0 "; future revisions of this API may
1919introduce new version numbers.
2020
2121## Request Format
@@ -39,7 +39,7 @@ Use the JWT with this header:
3939For example:
4040
4141``` curl
42- curl 'http://localhost:3000/api/v1 /clients' \
42+ curl 'http://localhost:3000/v1.0 /clients' \
4343-H 'Accept: application/json' \
4444-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJraWQiOm51bGwsImFsZyI6IkhTMjU2In0.eyJpZCI6MiwibmFtZSI6ImFkbWluIn0.JNtvokupDl2hdqB+vER15y89qigPc4FviZfJOSR1Vso'
4545```
@@ -86,33 +86,40 @@ SHOULD NOT be repeated.
8686# API Endpoints
8787
8888* Login
89- * [ POST /auth/basic] ( #post-authbasic )
90- * [ GET /auth/facebook] ( #get-authfacebook )
89+ * [ GET /auth/basic] ( #post-authbasic ) : lock : (client signed token required )
90+ * [ GET /auth/facebook] ( #get-authfacebook ) : lock : (client signed token required)
9191* API clients management
9292 * [ POST /clients] ( #post-clients ) :lock : (admin scope required)
9393 * [ GET /clients] ( #get-clients ) :lock : (admin scope required)
9494 * [ DELETE /clients/: key ] ( #delete-clientskey ) :lock : (admin scope required)
9595* Permissions
9696 * [ GET /permissions] ( #get-permissions ) :lock : (admin scope required)
9797
98- ## POST /auth/basic
99- Authenticates a user using Basic authentication . So far only an admin user is
98+ ## GET /auth/basic
99+ Authenticates a user using username and password . So far only an admin user is
100100allowed.
101101### Request
102- Requests must include a [ basic authorization header ]
103- ( https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side )
104- with ` username:password ` encoded in Base64.
102+ Requests must include a JWT signed with a valid client secret as the
103+ ` authToken ` query parameter.
104+
105105``` ssh
106- POST /api/auth/basic HTTP/1.1
107- Authorization: Basic YWRtaW46QXZhbGlkUGFzc3dvcmQuMA==
106+ GET /v1.0/auth/basic?authToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbn
107+ RJZCI6IjhlYWYxMjQ1MTEzNGIyNGUiLCJ1c2VybmFtZSI6ImFkbWluIiwicGFzc3dvcmQiOiIxLkxv
108+ bmdhZG1pbnBhc3MuMSIsInNjb3BlcyI6ImFkbWluIn0.foaQeXQGt5_8wFmW5mH9wdQLE3VKHwH9oD
109+ clmUroWRk HTTP/1.1
108110```
111+
112+ The payload of the signed JWT must include the following information:
113+ * ` clientKey ` : client identifier, aka his key.
114+ * ` scopes ` : the list of permissions the client is asking for for this token.
115+
109116### Response
110- Successful requests will produce a "201 Created" response with a session token
117+ Successful requests will produce a 200 response with a session token
111118in the form of a [ JWT] ( https://jwt.io/ ) with the following data:
112119``` json
113120{
114- "id " : " admin " ,
115- "scope " : " admin"
121+ "clientKey " : " 8eaf12451134b24e " ,
122+ "scopes " : [ " admin" ]
116123}
117124```
118125
@@ -124,9 +131,9 @@ Content-Length: 156
124131Content-Type: application/json; charset=utf-8
125132Date: Fri, 23 Sep 2016 16:22:39 GMT
126133{
127- "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImFk
128- bWluIiwic2NvcGUiOiJhZG1pbiIsImlhdCI6MTQ3NDY0Nzc1O
129- X0.R1vQOLVg8A-6i5QaZQVOGAzImiPvgAdkWiODYhYiNn4 "
134+ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IjhlYWYxMjQ1MTE
135+ zNGIyNGUiLCJzY29wZXMiOlsiYWRtaW4iXSwiaWF0IjoxNDc0NjQ3NzU5fQ.ZxnRCbuw
136+ yCypJMnAHHhpwSL_-y19Q4DSioA1cnB9JyY "
130137}
131138```
132139
@@ -137,16 +144,16 @@ Requests must include a JWT signed with a valid client secret as the
137144` authToken ` query parameter.
138145
139146``` ssh
140- POST /api /auth/facebook?authToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb
147+ GET /v1.0 /auth/facebook?authToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb
141148GllbnRJZCI6IjEyMzQ1Njc4OTAiLCJzY29wZXMiOlsidXNlci1mYXZvcml0ZXMiXSwiYXV0aFJlZ
142149GlyZWN0VXJscyI6WyJodHRwczovL2RvbWFpbi5vcmcvYXV0aC9zdWNjZXNzIl0sImF1dGhGYWlsd
143150XJlVXJscyI6WyJodHRwczovL2RvbWFpbi5vcmcvYXV0aC9lcnJvciJdfQ.e7rYEZsQNLG0aTjDRH
144151sQ2xembu3fyVe-B9bm8mFprwQ HTTP/1.1
145152```
146153
147154The payload of the signed JWT must include the following information:
148- * ` id ` : client identifier, aka his key.
149- * ` scope ` : just ` client ` for now .
155+ * ` clientKey ` : client identifier, aka his key.
156+ * ` scopes ` : the list of permissions the client is asking for for this token .
150157* ` redirectUrl ` : the URL you would like to be redirected after a
151158 successful login. This URL needs to be associated with your client
152159 information first. It will gets the user's JWT as a query parameter ` token ` .
@@ -172,12 +179,8 @@ with the following data:
172179
173180``` json
174181{
175- "id" : {
176- "opaqueId" : " facebook_id" ,
177- "provider" : " facebook" ,
178- "clientKey" : " 02e9c791d7"
179- },
180- "scope" : " user"
182+ "clientKey" : " 02e9c791d7" ,
183+ "scopes" : [" sensorthings" ]
181184}
182185```
183186
@@ -191,7 +194,7 @@ ___Parameters___
191194* permissions (optional) - List of permissions the client is allowed to request.
192195
193196``` ssh
194- POST /api /clients HTTP/1.1
197+ POST /v1.0 /clients HTTP/1.1
195198Content-Type: application/json
196199Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImFkbWluIiwic2NvcGUiOiJhZG1pbiIsImlhdCI6MTQ3NDY0Nzc1OX0.R1vQOLVg8A-6i5QaZQVOGAzImiPvgAdkWiODYhYiNn4
197200{
@@ -222,7 +225,7 @@ Get the list of registered API clients.
222225
223226### Request
224227``` ssh
225- GET /api /clients HTTP/1.1
228+ GET /v1.0 /clients HTTP/1.1
226229Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImFkbWluIiwic2NvcGUiOiJhZG1pbiIsImlhdCI6MTQ3NDY0Nzc1OX0.R1vQOLVg8A-6i5QaZQVOGAzImiPvgAdkWiODYhYiNn4
227230```
228231
@@ -250,7 +253,7 @@ Deletes a registered API client given its identifier.
250253
251254### Request
252255``` ssh
253- DELETE /api /clients/766a06dab7358b6aec17891df1fe8555 HTTP/1.1
256+ DELETE /v1.0 /clients/766a06dab7358b6aec17891df1fe8555 HTTP/1.1
254257Host: localhost:8080
255258```
256259
@@ -262,7 +265,7 @@ Get the list of client permissions.
262265
263266### Request
264267``` ssh
265- GET /api /permissions HTTP/1.1
268+ GET /v1.0 /permissions HTTP/1.1
266269Host: localhost:8080
267270```
268271
0 commit comments