Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User model #575

Closed
wants to merge 52 commits into from
Closed

User model #575

wants to merge 52 commits into from

Conversation

karlhorky
Copy link
Contributor

@karlhorky karlhorky commented Aug 15, 2018

Merging blocked on #536, #551, #555, #560, #562 and #563 because this PR contains commits from those PRs.

To use, rebuild containers:

docker-compose down
rm build/api build/api-db build/ssh build/auth-server
make build/api
make build/api-db
make build/ssh
make build/auth-server

Maybe also need to rm the build/yarn-workspace-builder file?

TODO:

  • Add new tables to database
  • Modify existing tables in database
  • Fix database views
  • Change JWT to include user id, not SSH key
  • Update ssh token command to verify SSH key against users
  • Migrations for database tables
  • Update stored procedures (ssh_key, project_ssh_key, customer_ssh_key)
  • Update all consumers of database tables and views (ssh_key, project_ssh_key, customer_ssh_key, permissions)
  • Make Drush automatic tokens compatible with new JWTs (do we still need to do this?)
  • Look for any code with potential to rely on old structure (ssh.+key)
  • Automatic migration script for existing data in old format
  • New additions to the DAO
  • Modifications to the DAO
  • New additions to GraphQL schema
  • Modifications to GraphQL schema
  • Update all queries and mutations from GraphQL consumers (including api-data.gql)
  • Comment in commented-out migrations
  • Fix tests
  • Update documentation

Later:

  • Tests for database (queries in DAO, also tables and views?)
  • Tests for GraphQL
  • Validation for user emails
  • CLI integration? (lagu users, lagu user)
  • Move DAO methods to more idiomatic GraphQL folder / file structure

Planning:

Database Tables

User fields partly inspired by Django User model

user (new)
userid email          firstname lastname
1      k@example.com  karl      horky

ssh_key (no changes)
sshid key
1     foo
2     bar

user_ssh_key (new)
userid sshid
1      1
1      2  // multiple SSH Keys per user

customer_user (previously customer_ssh_key)
customerid userid
3          1

project_user (previously project_ssh_key)
projectid userid
9         1

GraphQL

User {
  SshKeys: [
    {}
    {}
    {}
  ]
}

Project {
  Customer {
    Users [
      {}
      {}
      {}
    ]
  }
  Users [
    {}
    {}
    {}
  ]
}

@karlhorky karlhorky changed the title User model [WIPUser model Aug 15, 2018
@karlhorky karlhorky changed the title [WIPUser model [WIP] User model Aug 15, 2018
MariaDB doesn't care which way you do it, so let's just do it with the
parentheses in case we ever need parameters later.

> In current releases of MariaDB, CALL p() and CALL p are equivalent.

Ref: https://mariadb.com/kb/en/library/call/
To accept user IDs instead of SSH keys
This loops through all orphaned SSH keys (SSH keys without a related user in
user_ssh_key) and:

1. Creates a user
2. Creates a row in the user_ssh_key key to map the new user to the SSH key
3. Migrates all existing customer permissions to customer_user
4. Migrates all existing project permissions to project_user
- Move SSH key DAO functions to user.js, refactor
- Add new user DAO functions
- Rewrite stored procedures to use Knex
- Update old GraphQL queries
- Add new GraphQL queries
- Add userBySshKeys query
@karlhorky karlhorky changed the title [WIP] User model User model Aug 28, 2018
@karlhorky
Copy link
Contributor Author

karlhorky commented Oct 3, 2018

Hm, lots of merge conflicts in the new changes from master. Since we have these commits also in #632, I'm going to close this PR and let #632 supersede this, fixing the conflicts over there.

Update: Now #675 has superseded #632.

@karlhorky karlhorky closed this Oct 3, 2018
@karlhorky karlhorky deleted the user-model branch October 9, 2018 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant