Code Monkey home page Code Monkey logo

odst's Introduction

ODST (Operational Development Software Team)

Table of Contents

Group Culture

Every workday there is a Daily Scrum in the team area (after the flight standup) for the developers. There we discuss roadblocks, what we did the previous work day, plans this current day and so forth. You and your partner are expected to complete the tasks together; if research is needed, you’ll both be expected to conduct it. This ensures knowledge sharing occurs. Cell Phone use in the team area will be kept to a minimum. Breaks can be taken outside of the team area where members can use their phones freely. Responsibility for how long and frequent breaks occur will be at the discretion of the member until it becomes an issue. Members are expected to attend all Scrum Events to include: Backlog Grooming, Sprint Planning, Daily Stand-ups, Sprint Reviews, and Sprint Retrospectives. Please plan leave, appointments, meetings, and volunteer opportunities around these important events.

We use Google Calendar for tracking all Scrum Events, Leave, Appointments, Squadron/Flight events, etc.

Website Registration

You will need to register for accounts through all these sources before setting up your development environment.

Setting up Development Environment

Visual Studio Code

  • VS Code is a text editor, but one that is extensible with diverse types of plugins. With these plugins VS Code turns into a “IDE” that combines version control, Intellisense, Live Share, formatting, and many other QoL features. We need an IDE to edit JavaScript/typescript projects. Download here, Visual Studio Code - Code Editing. Redefined.

  • Make sure you click on “Open w/ Code” functions in the installer

  • After installing, make sure to enable execution policies if you are on windows. about Execution Policies - PowerShell | Microsoft Docs

    • Run on an Administrator Powershell: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
  • Be sure to add the recommended extensions to VSCode, a list can be found in the .vscode/extensions.json file in the repository

Node.JS

  • Node.JS is a JavaScript runtime environment that allows for front-end and back-end work using the JavaScript programming language. It allows us to run JavaScript on a server/desktop as opposed to just in the browser. For Windows/MAC users, download the latest version here, Download | Node.js (nodejs.org). Get the “LTS” version (IMPORTANT!)

Nest.JS GLOBAL

  • You will need to run this after installing node. Copy and paste this onto the command prompt. Note that MAC users/Linix machines may not be able to simply copy and paste do to different ASCII characters. Do not forget to add “sudo” in front of it for Mac/Linux.

    • npm install –g @nestjs/cli

Yarn

  • Install YARN, we are using this instead of NPM for our package manager

    • npm install -g yarn

Git

  • Regardless of what Git system you use (vanilla command line, vanilla git GUI, built into your IDE, a desktop client, etc) you need to download the Git tools. These can be found here, Git - Downloads

  • For MAC users, install Homebrew first w/ the instructions here, The Missing Package Manager for macOS (or Linux) — Homebrew

  • Ensure that you change the CRLF settings to: Checkout as-is, commit as-is (Dont worry about this step if using MAC)

WSL 2

  • Install Ubuntu | Microsoft Store

  • In PowerShell, set Ubuntu WSL to version 2

    • wsl --set-version ubuntu 2
  • In WSL (Ubuntu), make sure to update it

    • sudo apt update
    • apt list -–upgradable
    • sudo apt upgrade
  • Return to PowerShell and ensure WSL 2 is installed

    • wsl -l -v

Docker (Rancher Desktop)

[Windows/Linux]

  • You will need to install WSL 2 as part of this if you are on windows, refer to the section above. The below instructions are for Windows/Debian (Ubuntu is Debian).

[Rancher Desktop]

  • Install Rancher Desktop, Installation | Rancher Desktop Docs. Launch it and wait for it to finish installing the required packages. Use the dockerd runtime if anything asks for it.

  • Open the ODST repository in VSCode and open a Rancher WSL terminal. Ensure it's working by runnning the following command

    • docker container run hello-world
  • Use apt to install the appropriate packages to be able to transfer files over http, get certificate authorities, ensure curl is installed and install a tool to communicate to your linux distro.

    • sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
  • Download the GPG key for Docker:

    • curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  • Install the stable version of Docker

  • Go to this Pastebin and copy and paste the contents into wsl

  • Install Docker Utilities:

    • sudo apt update
    • sudo apt install docker-ce docker-ce-cli containerd.io
    • sudo apt install docker-compose
  • You will need to start Docker in WSL after every restart:

    • sudo service docker start
  • Test that it is working:

    • sudo docker run hello-world

[Ironbank]

  • Create an Ironbank account

  • Log in to Harbor

  • Go to User Profile and copy CLI Secret

  • In WSL, run sudo docker login registry1.dso.mil -u=YOUR_USERNAME (Login with your username replacing YOUR_USERNAME and CLI secret for your password)

  • If logging into IronBank via WSL throws an error regarding not being able to store credentials, you have to make a GPG key

    • Run gpg --gen-key
    • Choose option 1
    • Choose a bit size
    • Choose 0, does not expire, and then Y to confirm
    • Give name and email (used to generate user ID), then O to confirm
    • Create a passphrase
    • Find output line gpg: key [KEY] marked as ultimately trusted, this is your key
    • Run pass init KEY replacing KEY with your key
  • Youhould now be able to execute:

    • sudo docker pull registry1.dso.mil/ironbank/opensource/postgres/postgresql12
  • Navigate to the ODST repo on WSL and run

    • sudo docker-compose up postgres -d (This method will support docker-compose files up to version 3.7)
  • Now start your image

    • docker compose up -d

Insomnia

References

Nx Console

Admin user account for graphql API access

password: admin
username: admin

Docker

Build image locally

docker build . --file ./apps/{app}/Dockerfile

Build & push via nx

nx docker {app}

Careful with this, due to that it pushes it up with the :latest tag. Add --push=false to not push built images up to registry.

Migrate database via docker

docker-compose up ods-migrate

Start all services listed in docker-compose

docker-compose up ods

Add -d to start them in the background; can change ods to another service if you'd like. ods is dependent on ods-api, which is in turn dependent on postgres, so just specifying ods will start entire stack. If you only say docker-compose up, all services will be started, including ods-migrate.

Start to finish full docker stack

#migration
docker compose up ods-migrate

#ods stack
docker-compose up ods -d

Docker images/tags

ods: ods:latest, ods:v0 ods-api: ods-api:latest, ods-api:v0 ods-migrate: ods-api:migrate, ods-api:v0-migrate

Common Troubleshooting steps

- yarn throws graphql error

This could be because you've made changes to the schema and didn't rerun the backend. Serving the backend and running yarn again will ensure the graphql schema and types will be generated properly.

- Webpack config errors on frontend

Need to remove prisma references from frontend and only use the generated graphQL files.

- New prisma database

When creating a new prisma database, you need to specify what project it is made for in the prisma.schema under outputs.

- Tailwind isn't working w/ Material

Ensure that you marked Tailwind as "Important" under tailwind config.

- No loader available on a .graphql file in frontend

Don't import from the .graphql file, import from .generated file

- "excesive stack depth" error on prisma/graphql types

Coerce the type to the expected prisma type. Will probably need to do it on resolver.
Example: UserWhereInput as Prisma.UserWhereInput

odst's People

Contributors

yurisim avatar sayntonge avatar pmeskridge avatar brendenmcgrew avatar andydawg313 avatar snyk-bot avatar ericcater avatar mikehickey7 avatar dependabot[bot] avatar redrick696 avatar addginger4flavor avatar matthew-eichler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wooodhead

odst's Issues

[2] Password Validation

bcrypt can have unexpected behavior when password length is 72 or over characters. So max length should be set to 50 or something.

Frontend

  • Has a symbol
  • Has a number
  • 12 characters minimum
  • does not contain their username
  • Has a mix of lower and upper characters
  • 48 characters max

Backend

  • 48 characters max

[2] Validate Org Pipe

  • 2. name Format of Number + letters like "552 ACNS" or "5 AHKS/KOT"
  • Verify that pipe functions on nest

process.env does not work with nx

process.env.KEY is supposed to be able access the value associated with the given KEY. Currently it does not. Possible need to prefix the key with NX_ e.g. NX_KEY.

[Break] SQL Joins On Security Code vs Clearance

  • Create UI Design to upload Documents (figma) - 3
  • Implement UI on Frontend - 2
  • Allow user to specify what columns mean what (figma) - 3
  • Implement figma design on column specification - 5
  • Send documents to backend - 5
  • Parse column data from 3 documents to put into person's record on DB - 2
  • Create joins for code data to place into person's file - 2
  • Display discrepancies (figma) 2
  • Implement discrepancies (angular) - 3

[3] Figma Mockups for Sign In

  • Research how animations work so that you don't have to make a new screen when we click on "Reset Password" (Copy Fuse)
  • Make Create Person screens / Create Org screens
  • View Person/ View Org

[3] Work w/ Serqet on E2E Tests

  • Help Goad with Nx Workshop, https://github.com/nrwl/nx-workshop
  • Walk Goad through pipeline
  • Startup Postgres Image... somewhere (there is already a docker-compose file in our repo that points to the ironbank postgres image, need to login)
  • Need to migrate prisma to it
  • Start up Backend. Y'all have the option of either serving it via Nx or making a docker image of it. The Dockerfile to make the docker image is similar to this one, https://dev.to/erezhod/setting-up-a-nestjs-project-with-docker-for-back-end-development-30lg
  • Connect backend to postgres, we've made it easy by just giving the backend the environment variable of the connection string. Refer to .env.local for reference.
  • Run the e2e test. We may need to reconfigure the graphQL connection string if yall decide to put it on a port that is not 3333.

[2] Validate Person Pipe

  • dodId 10 digits
  • email valid email
  • middleInitial 1 Character
  • birthDate 1900 floor
  • height max of 100 inches
  • Validate these apply on NestJS tests

[3] Modify findManyInOrg to only return the individuals of the requester' organization

For example, if these people exist in a database

  • Bob Jones, in the 552 ACNS
  • Bob Rones, in the 552 ACNS
  • Job Bones, in the 752 OSS
  • Rob Bones, in the 552 ACG

if Bob jones uses findManyInOrg, only return himself + Bob Rones. Meanwhile Rob Bones gets all 4.

Make sure to architect this in a manner than allows someoen to easily change this to also get everyone in their parent org if requirement changes. So Bob Jones can view all in the ACG.

[3] When an api call is made, value is returned in unknown type

To access the requested data, the returned value has to be cast to any then accessed via a property (which appears to be fairly arbitrarily named) then cast to the expected value.

For example

...
.then(({ data }) => {
const tokens = (data as any)?.refreshTokensVar as TokensGQL; //TODO make better
}

Look at UnauthorizedExceptions thrown in auth flow

UnauthorizedException's are thrown when user does not have valid credentials; some of them are thrown to indicate user needs to refresh tokens. But others are thrown when user needs to log in with username/password (or something else). There needs to be differentiated between so frontend can handle them properly.

[3] Allow user to reset password

"Forgot password" link on login screen to allow user to receive email to reset password. Link in email needs to expire.

Should there be a "Forgot username" too?

Frontend

  • "Forgot password" link
  • Makes forgot password api call

Backend

  • generate url to allow user to reset password
  • send email to user's email
  • Link should expire after x hours

Logout Api endpoint

A logout api is not required, since it's part of JWTs/the auth flow being decentralized that they aren't required. The frontend handles logging out the client. The endpoint would just revoke the current refresh token/

From a day to day standpoint, this is of basically no value. But it would help protect again an attacker who steals a refresh token, waits for victim to go inactive then using refresh token to authenticate. Token reuse would not protect against that, but a logout functionality would (mitigate it at the very least).

I'm leaning towards not implementing it.

Implement keyid in jwt tokens

JWT tokens are generated with a secret. To verify the JWT, the secret is used. If the secret is rotated (which it should be), a JWT might be used that needs an older secret to verify. To facilitate this, secrets need an id, then that id is stored in the JWT payload.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.