QMd
  • QMd
  • About
    • Features
    • Security and Privacy
    • Validation
    • Credits
  • Installation
    • Basic Deployment
    • Advanced Deployment
    • MongoDB Compass Install
  • Help
    • Guide for Admin
    • Guide for Survey Participants
  • Documentation
    • Configuration/Environment Variables
    • Survey API
    • Users API
    • Auth API
    • Models
    • Angular Components
Powered by GitBook
On this page
  • API
  • Check Login Data
  • Checking Authentication Token
  • Expiring Token Cookie
  • Middleware
  • Importing Into Component
  • Functions
  1. Documentation

Auth API

Description of the functionality of Authentication API

PreviousUsers APINextModels

Last updated 6 years ago

API

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

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

Expiring Token Cookie

<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]

​

API