@@ -8,16 +8,20 @@ with authentication and access control mechanisms in place.
88
99## Authentication
1010
11- Authentication for Signal K REST and WebSockets connections is based on http cookies or tokens carried in the HTTP
11+ Authentication for Signal K REST and WebSockets connections is based on HTTP cookies or tokens carried in the HTTP
1212header.
1313
14- ### Logging into a server via HTTP
14+ ### Authentication via HTTP
1515
16- A device or a web client can login to a Signal K server using User Name and Password using a REST request.
16+ A device or a web client can authenticate with a Signal K server by providing a username and password via a standard
17+ HTTP POST request to ` /signalk/«version»/auth/login ` .
1718
18- The URL for the request is ` /signalk/v1/auth/login ` and should be a POST with either ` Content-Type ` of
19- ` application/json ` with the properties ` username ` and ` password ` in the body OR ` Content-Type ` of
20- ` application/x-www-form-urlencoded ` for web based login forms.
19+ The ` «version» ` field is the endpoint version identifier chosen by the client from those offered by the server. See the
20+ [ REST API] ( rest_api.md ) documentation for the structure of these identifiers.
21+
22+ The client may send the login request with a ` Content-Type ` of ` application/json ` with the properties ` username ` and
23+ ` password ` in the body OR with a ` Content-Type ` of ` application/x-www-form-urlencoded ` with the ` username ` and
24+ ` password ` fields.
2125
2226``` json
2327{
@@ -26,8 +30,8 @@ The URL for the request is `/signalk/v1/auth/login` and should be a POST with ei
2630}
2731```
2832
29- In response to a valid login, the server will set a HTTP cookie and include the token type and the token value in the
30- body of a HTTP 200 response. The response ` Content-Type ` must be ` application/json ` .
33+ In response to a valid login, the server shall respond with a 200 (OK) status, set an HTTP session cookie and include
34+ the token type and the token value in the body of the response. The response ` Content-Type ` must be ` application/json ` .
3135
3236``` json
3337{
@@ -38,9 +42,9 @@ body of a HTTP 200 response. The response `Content-Type` must be `application/js
3842
3943In response to invalid login information the server must return HTTP error code 401 (Unauthorized).
4044
41- If the server does not implement this authentication mechanism it must return http error code 501 Not implemented.
45+ If the server does not implement this authentication mechanism it must return HTTP error code 501 ( Not implemented) .
4246
43- ### Logging into a server via Web Sockets and similar transports
47+ ### Authentication via WebSockets and Similar Transports
4448
4549The client should send a message like the following.
4650
@@ -73,17 +77,17 @@ If the login fails, the server will send a response like the following:
7377{
7478 "requestId" : " 1234-45653-343454" ,
7579 "state" : " COMPLETED" ,
76- "result" : 401 ,
80+ "result" : 401
7781}
7882```
7983
80- ### Providing authorization to the server in subsequent requests
84+ ### Providing Authorization to the Server in Subsequent Requests
8185
82- #### Web based clients
86+ #### Web Based Clients
8387
8488Web based clients should be sure to include the cookie set in the authentication response in all subsequent requests.
8589
86- To logout, a web based client should send an HTTP PUT request to ` /signalk/v1 /auth/logout ` .
90+ To logout, a web based client should send an HTTP PUT request to ` /signalk/«version» /auth/logout ` .
8791
8892#### WebSockets Clients
8993
@@ -92,7 +96,7 @@ Clients can include the authentication cookie with the initial request.
9296Clients can include the ` Authorization ` HTTP header with the initial connect request. The format of the header should
9397be ` {type} {token} ` , for example ` Authorization: JWT eyJhbGciOiJIUzI1NiIsI...ibtv41fOnJObT4RdOyZ_UI9is8 `
9498
95- #### Other clients
99+ #### Other Clients
96100
97101Clients using other kinds of protocols can include the ` token ` in the Signal K messages they send.
98102
@@ -110,5 +114,5 @@ Clients using other kinds of protocols can include the `token` in the Signal K m
110114
111115## Device Access
112116
113- Devices that don’t have any user interaction, like sensors with no input mechanisms, should acquire a token using
114- Access Requests: [ Appendix E: Access Requests] ( access_requests.md )
117+ Devices which don’t have any user interaction such as sensors with no input mechanisms should acquire a token using
118+ the [ Access Requests] ( access_requests.md ) mechanism.
0 commit comments