Skip to content

Latest commit

 

History

History
353 lines (257 loc) · 9.31 KB

doc.md

File metadata and controls

353 lines (257 loc) · 9.31 KB

Internal Documentation of When- Rutgers Calendar Service OSS

Table of Contents

  1. Get Started
  2. Server



Get Started

Set Up

  1. Environment Variable

    1. cd backend/api

    2. Create .env file with reference to example_env.txt

      ADMIN: used to access service account and perform tasks, must be an admin account in the domain
      DOMAIN: target domain

  2. Set up docker container

docker compose build



Run the program

With docker

docker compose up



CAS

CAS Integration

  1. Follow the README.file on mod_auth_cas

  2. Add cert

    1. Download the InCommon Certificates for CAS service from Rutgers CAS certificate.



Server

Database

Rutgers Calendar Service stores its data in MongoDB local Database.

The main database is when

Overview

├── when

│ ├── subcals

│ ├── subscriptions

│ ├── groupsubscriptions

│ ├── admins

subcals

subcals is the colleation that stores all subscrideble calendars.

Each document is one subscrideble calendars

  • summery [string] : summery(title) of the google calendar
  • calendarId [string]: unique id for the google calendar
  • description [string]: a description of what the google calendar is for
  • netId [string]: the netId of the host of the calendar
  • organization [string]: the organization the calendar belongs
  • createdTime [Datetime]: the time when admin adds the calendar to database
  • editedTime [Datetime]: latest edited time
  • numSub [int]: total number of subscriptions
Example
{
    _id: ObjectId('66998ca579b05baf30b3af4d'),
    summary: 'Academic Calendar',
    calendarId: 'c_cef2ddd17b7974627cdab796544ddb5e0091d0cb3b8d5c4f79034293a71ae71b@group.calendar.google.com',
    description: 'Rutgers Univerisity-wide Academic Calendar',
    netId: 'abc123',
    organization: 'Rutgers Univeristy',
    createdTime: '2024-07-18T21:44:05.091Z',
    editedTime: '',
    numSub: 3
  }

subscriptions

subscriptions is the colleation that stores all cases of calendar subscriptions

Each document is one case of calendar subscriptions

  • calendarID [string] : unique id for the google calendar
  • netID [string]: netID of the user that subscribed to the calendar
  • time [Datetime]: time of subscription
Example
{
    _id: ObjectId('669e9dc2f798dd7f971fa3c3'),
    calendarID: 'c_cef2ddd17b7974627cdab796544ddb5e0091d0cb3b8d5c4f79034293a71ae71b@group.calendar.google.com',
    netID: 'abc123',
    time: '2024-07-22T17:58:25.197Z',
}

admins

admins is the colleation that stores all admins for when.

Each document is one admin

  • netID [string] : netID of the admin
  • createdTime [Datetime]: time when admin is being added
Example
{
    _id: ObjectId('66995f3ba2449285b4149f48'),
    netID: 'abc123',
    createdTime: '2024-07-18T18:30:19.172Z'
  }

Admin Management

admins can only be added and edited manually through mongo

Add an admin

  1. mongosh
  2. use when
  3. db.admins.insertOne({ netID: "abc123", createdTime: new Date()})



Network

REST API

Port 8080

  • Description: This port is used by the application server to handle incoming HTTP requests.
  • URL:localhost:8080

Endpoint Structure


Data

/data/:summary/[:detail]

  • summary: short summary of the content of the data
  • detail: to get specific part of the data (optional)
Get SubCals Data
  • Description: This endpoint returns all subscribable calendars in the database.

  • URL: /data/subcals

  • Method: GET

  • Success Response:

    Code: 200 OK
    Example Response Body:

      0: Object{
          "summary": "Spring 2024 Academic Calendar",
          "id": "c_cef2ddd17b7974627cdab796544ddb5e0091d0cb3b8d5c4f79034293a71ae71b@group.calendar.google.com"
      },
      1: Object{
          "summary": "Test 1",
          "id": "c_c05ef1daf37942ea1edc613cd0c294b0054a711f4470155d6e357579d29134b2@group.calendar.google.com"
      },
    

Request

/request/:role/:type/:id

  • type: the type of request
  • role: the role of the client sends the request (admin/user)
  • id: unique identifier for each request
User Request: Subsribe to Calendar
  • Description: This endpoint returns the calendar user reuqest to subscribe
  • URL: /request/user/subscirbe-calendar/:id
  • Method: POST
Admin Request: Add Calendar to subcals Database
  • Description: This endpoint returns the calendar to be added to subcals database
  • URL: /request/admin/add-calendar/:id
  • Method: POST

Request Results

/request-results/:id

  • id: unique identifier previously assigned for the request
Get SubCals Data
  • Description: This endpoint returns all subscribable calendars in the database.
  • URL: /data/subcals
  • Method: GET

Google API

Service Account

Service account represents a Google Cloud service identity, use to connect to API service and make requests to google API. To access the service account used in this project

  1. Enter Google Cloud Console's Calendar Service Project with an developer account under the domain
  2. In Navigation Menu (side bar) => IAM & Admin => Service Account

Service account Key

Used to identify and authenticate the service account.
Currently Used Service Account Key:

Access this key with service-account-key1.json.




Error and event

Network 100-199

Code Description
201 Title
102 Text
202 Fail to load collection from mongodb database

| 110 | Fail to decode Json file from frontend|

Database 200-299

Code Description
201 Title
202 Text
202 Fail to load collection from mongodb database
210 Error occurs when inserting item into database
211 Item already existed in the collection when attempting to add
220 Error occurs when finding item in database
221 Item doesn't exist when attempting to find
222 Item exists, required attribute missing
223 Item exists, current user doesn't have permission to edit
230 Error occurs when deleting item in database
240 Error occurs when updating item in database

API 300-399

Code Description
201 Title
202 Text
202 Fail to load collection from mongodb database
310 Error occurs when using calendarmod Go Package
311 Error occurs when subscribing user with calendarmod Go Package
312 Error occurs when subscribing group with calendarmod Go Package
321 Error occurs when send mail

TESTING 500-599

Code Description
501 Log in as User
502 Log in as Admin



Error + Solution

Google API
  • JWT Token Incalid for Google API

    Post "https://www.googleapis.com/calendar/v3/calendars?alt=json&prettyPrint=false": oauth2: cannot fetch token: 400 Bad RequestRespons: {"error": "invalid_grant", "error_description": "Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values and use a clock with skew to account for clock differences between systems." }

    1. Trivial Solution: Reboot device
    2. Sync server with NTP a. Run timedatectl b. Refer to the followeing to enable system sync and ntp service



To Contribute

To-do List

High Priority

  • Dynamic Calendar doesn't support full-day event, has to have valid start and end time
  • EventForm.tsm- reoccurance feature
  • EventForm.tsm- Guest accesibility feature
  • LoginPage.jsx- login authenitification
  • Create a database for subscribable calendars

Future Implementation

  • Create base admin account to manage for calendar service (currently using [email protected])



External Resources

Rutgers Google Util

Calendar Service is developed from rutgers google util, reference to this project to see the implementations of following utilities:

  • Get all users from an Google admin account (func getAllUsers)
  • View google drive of an account
  • Use terminal to access and change calendar events

Access Rutgers Google Util on GitLab