Auth API
Description of the functionality of Authentication API
Last updated
Description of the functionality of Authentication API
Last updated
Note: The following is defined in express/routes/auth.route.js
<url>/auth
i.e. http://localhost:8080/auth/
Method
Description
Access
POST
Responds status 200 if valid, 400 if invalid
Public
<url>/auth/ token
i.e. http://localhost:8080/auth/token
Method
Description
Access
GET
Responds status 200 if token is valid, 400 if invalid
Public
<url>/auth/ remove_token
i.e. http://localhost:8080/auth/remove_token
Method
Description
Access
GET
Removes Cookie, Responds with 200
Public
Access through src/app/auth.service.ts
import { AuthService } from '../../survey.service';
... export class ... { constructor( ... , private authservice: AuthService) }
src/app/auth.service.ts
Contacts Auth API through HTTP to login and gain administrator access to private API calls.
login(admin: Admin)
Param
Type
Description
admin
Admin
Admin Object (Username/Password)
return
HttpResponse<>
HttpErrorResponse
Response (200) [with secure cookie with JWT token] if successful
Response (400) if invalid
Note: Cookie returned has form [ 'SESSION_ID', <token> ] with httpOnly, secure and strict flags set and an expiry depending on the settings configuration (default 7200 seconds).
Queries Auth API through HTTP given a cookie containing a JWT generated token (from the express, if a user/survey with these ids is in the database, returns user corresponding to this id pair.
checkAuth()
Param
Type
Description
return
HttpResponse<>
HttpErrorResponse
Response (200) if successful
Response (400) if invalid [deletes invalid cookie]
Queries Survey API through HTTP to delete the secure token cookie.
logOut()
Param
Type
Description
return
HttpResponse<>
Response (200) [expires cookie]