Auth API

Description of the functionality of Authentication API

API

Note: The following is defined in express/routes/auth.route.js

API

Check Login Data

<url>/auth

i.e. http://localhost:8080/auth/

Method

Description

Access

POST

Responds status 200 if valid, 400 if invalid

Public

Checking Authentication Token

<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

Middleware

Access through src/app/auth.service.ts

Importing Into Component

import { AuthService } from '../../survey.service'; ... export class ... { constructor( ... , private authservice: AuthService) }

Functions

src/app/auth.service.ts

Checking Login Data

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

Checking Authentication Cookie

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]

Logging Out/Expiring Cookie

Queries Survey API through HTTP to delete the secure token cookie.

logOut()

Param

Type

Description

return

HttpResponse<>

Response (200) [expires cookie]

Last updated