Git Product home page Git Product logo

myproxy's People

Contributors

albertoelopez avatar allopez7 avatar anso3 avatar bryanjenningz avatar coltonehrman avatar dependabot[bot] avatar ggwadera avatar hwong0305 avatar joshgreenwell avatar rkalra247 avatar sahilkalra98 avatar slybouhafs avatar songz avatar wolfy64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

myproxy's Issues

Create an acme service

acme service should have the following signatures:

const {renewCert} from './adapters/acme'
...
// sample inputs:
// ('*.innout.life', 'dns_gd', {GD_Key: ..., GD_Secret: ...})
renewCert(domain, service, tokens)

For now, just support acme's goDaddy's API: https://github.com/Neilpang/acme.sh/wiki/dnsapi#4-use-godaddycom-domain-api-to-automatically-issue-cert

Sample implementation of renewCert:

// file root:
const serviceMapping = {
  dns_gd: ['GD_Key', 'GD_Secret']
}
const renewCert = (domain, service, tokens) => {
  const envVars = (serviceMapping[service] || []).reduce( (acc, key) => {
    return `${acc} ${key}=${tokens[key]}`
  }, '')
  execShell(`${envVars} acme.sh --issue --dns ${service} -d ${domain}`)
}

REST (GET) for available domains

After this issue: #60

We need to retrieve the list of available domains so we can surface it on the home page (to create a mapping). Therefore, we need a GET /availableDomains

Proxy

Grouped by PR:

  1. app.listen should only be called if ADMIN environment is present. If not present, app.listen should not happen, and it should log message: 'Admin UI/API is turned off'
  2. Create a HTTPS server, listening to port 443. Handle SNICallback to send the ssl certificates. For all requests, just send back "Hello World"
  3. From the hostname, lookup mappings db to find the correct port, then proxy to the port.
  4. Create an express server to listen to http requests on port 80. Redirect every request to https domain (make sure path and query parameters are included in the redirection).

Admin page setup

Admin app should run on port 20000.

if no cookie, prompt for admin password. Admin password input = access to admin page.

Admin password is set up by environment variables. For example:

ADMIN=9458237 yarn start

create setup script

when users run yarn setup, the following should happen:

  1. clone this project into project root (should be in gitignore)
  2. run chmod +x ./acme/acme.sh so that the script has execution access
  3. run yarn

Re-organize API folder

api/ folder is confusing... inside we have all routes (except /admin/providers), lib/ types/ folder...
We might add a routes folder with api.ts and admin.ts and move out lib/,types into /src ?

lib and types should be in src folder

Setup views

create views folder and setup ejs rendering template

Question about prod.config.js

Does it make sense for a user that not use pm2 to have this file?
I think this file should not be on Github only on the server same for deploy.sh.
OR
We can add pm2 as dependency and change npm start to run it ?

module.exports = {
  apps: [
    {
      name: 'myProxy-prod',
      script: './build/app.js',
      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      env_production: {
        NODE_ENV: 'production', 
        PORT: 3000, // Should be setup with Process.env.PORT
        ADMIN: '123' // Should be setup with Process.env.ADMIN
      },
    },
  ],
}

Mappings

mappings current accept domain, ip, and port. We need an additional field subdomain. Total:

ip
port
domain
subdomain

Throw a error on the first app launch

Throw a error on the first app launch on npm run start just after npm run setup

internal/modules/cjs/loader.js:716
    throw err;
    ^

Error: Cannot find module '/home/dev/david/app.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:713:15)
    at Function.Module._load (internal/modules/cjs/loader.js:618:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

BUG: SSL Cert generation is not working

Please fix this API endpoint. Its a blocker, because without availableDomains nothing works. https://github.com/garageScript/myProxy/blob/master/src/api/admin.ts#L14

Update 9/16
POST /sslCerts is still not creating certificates in production. Please take note of the picture below:

  1. When you test, please remove the existing key/ cert. SSL cert generation takes > 30 seconds per cert. So if we are generating 2 certs (root and wildcard), the post request should take 60 seconds.
  2. We are chaining the cert generation command using &. This means background, so the env variables set is not applied. I would use ; instead.
  3. Make sure the post request does not time out (possible up to 1 minute wait).

Screen Shot 2019-09-16 at 1 54 38 PM

UI creation page

As a developer, I would like to create a mapping for available domains.

Screen Shot 2019-09-03 at 1 42 51 PM

  1. clicking on the button should submit a POST request /mappings to create a mapping
  2. When mapping has been created, display the mappings in a list, like this image:

Screen Shot 2019-09-03 at 1 45 41 PM

3. (Separate Issue, should not be done as part of this issue). Dropdown must be populated by the Service in this issues: https://github.com//issues/61 https://github.com//issues/60

Admin UI to manage serviceHostKeys

Admin UI should live at /admin/serviceHostKeys, should display a list of keys, with 3 input boxes at the top for users to quickly create serviceHostKeys. Refer to api to see details about inputs you will need.

list of keys must be grouped by the service key. Refer to image below:

Screen Shot 2019-08-12 at 11 05 04 PM

Note on the above image.
Like the rest, service title section should be editable like the rest of the rows. It is only deletable if there are no more keys in that service.

BUG: api requests times out if users are not admin

To reproduce:
Delete all cookies.
Screen Shot 2019-09-06 at 10 23 51 AM

Go to root path.
Look at network tab
API request to /api/mappings does not receive response.


Expected behavior:
Should return status code 401 for protected endpoints (/api/admin)
Should not fail for non protected endpoints. (i.e./api/mappings)

Admin API to manage api key / secret

Create REST apis for serviceHostKeys to store keys to be used for acme ssh key generation

POST /api/admin/serviceHostKeys

{
  key: 'DNSimple_OAUTH_TOKEN',
  value: 'User-Input',
  service: 'dns_dnsimple'
}

PATCH, PUT, DELETE, GET should be self explanatory.

API will be used to power the UI here: #12

Host Keys `Undefined`

As a user I have no idea what I have to add into the input field.(Undefined).
We should explain what to do and add default value

Screen Shot 2019-09-12 at 1 24 46 AM

Overview

Goal

Part 1: Admin

  1. Admin: Users should be able to save their serviceKeys so that myProxy can use it to retrieve their domains and verify ssl challenge.

User logs in to their GoDaddy account, finds their apiKey/secret. Copies them and paste it so that we can save it.
Example:

      service: GoDaddy.   
      key1: API_KEY.   
      key2: API_SECRET.   
  1. After user saves the service Keys, we hit the service to retrieve all the domains that they own. Next to each domain, there will be a button setup
  2. When user clicks on the setup button, we do 2 things:
  1. run acme.sh script with service keys.
  2. Update the CNAME records for the domain using the service APIs so that all requests going to the domain will go to the server running myproxy

Part 2: User

  1. User goes to application page. All domains that are setup will be in the dropdown. User can type in any subdomains
  2. When user creates an domain, create a port for them automatically that they can run their apps on.

Part 3: Proxy

  1. When request comes in to https domain, find the port and forward it accordingly.

CircleCi - Deploy Over SSH Fail

Error:

fatal: not a git repository (or any of the parent directories): .git
npm ERR! path /home/dev/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/dev/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dev/.npm/_logs/2019-08-29T15_57_10_822Z-debug.log
npm ERR! path /home/dev/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/dev/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dev/.npm/_logs/2019-08-29T15_57_11_049Z-debug.log
[PM2][ERROR] File ./scripts/prod.config.js not found
Exited with code 1

Error: ENOENT: no such file or directory, open './data.db'

Throw an error on the first run is a bad user experience.
We should create ./data.db on npm run setup

File does not exist, but do not worry. File will be created on first save [Error: ENOENT: no such file or directory, open './data.db'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: './data.db'
}

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.