Commit Graph

154 Commits

Author SHA1 Message Date
Kyle Carberry 7ad87505c8
chore: move agent functions from `codersdk` into `agentsdk` (#5903)
* chore: rename `AgentConn` to `WorkspaceAgentConn`

The codersdk was becoming bloated with consts for the workspace
agent that made no sense to a reader. `Tailnet*` is an example
of these consts.

* chore: remove `Get` prefix from *Client functions

* chore: remove `BypassRatelimits` option in `codersdk.Client`

It feels wrong to have this as a direct option because it's so infrequently
needed by API callers. It's better to directly modify headers in the two
places that we actually use it.

* Merge `appearance.go` and `buildinfo.go` into `deployment.go`

* Merge `experiments.go` and `features.go` into `deployment.go`

* Fix `make gen` referencing old type names

* Merge `error.go` into `client.go`

`codersdk.Response` lived in `error.go`, which is wrong.

* chore: refactor workspace agent functions into agentsdk

It was odd conflating the codersdk that clients should use
with functions that only the agent should use. This separates
them into two SDKs that are closely coupled, but separate.

* Merge `insights.go` into `deployment.go`

* Merge `organizationmember.go` into `organizations.go`

* Merge `quota.go` into `workspaces.go`

* Rename `sse.go` to `serversentevents.go`

* Rename `codersdk.WorkspaceAppHostResponse` to `codersdk.AppHostResponse`

* Format `.vscode/settings.json`

* Fix outdated naming in `api.ts`

* Fix app host response

* Fix unsupported type

* Fix imported type
2023-01-29 15:47:24 -06:00
Steven Masley b0a16150a3
chore: Implement standard rbac.Subject to be reused everywhere (#5881)
* chore: Implement standard rbac.Subject to be reused everywhere

An rbac subject is created in multiple spots because of the way we
expand roles, scopes, etc. This difference in use creates a list
of arguments which is unwieldy.

Use of the expander interface lets us conform to a single subject
in every case
2023-01-26 14:42:54 -06:00
Steven Masley 08cce81ac8
feat: Implement allow_list for scopes for resource specific permissions (#5769)
* feat: Implement allow_list for scopes for resource specific permissions

Feature that adds an allow_list for scopes to specify particular resources.
This enables workspace agent tokens to use the same RBAC system as users.

- Add ID to compileSQL matchers
* Plumb through WithID on rbac objects
* Rename Scope -> ScopeName
* Update input.json with scope allow_list

Co-authored-by: Cian Johnston <cian@coder.com>
2023-01-19 13:41:36 -06:00
Marcin Tojek deebfcbd53
feat: Validate swagger definitions (#5694)
* docs: audit, deploymentconfig, files, parameters

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

* Fix

* WIP

* WIP

* Users

* Logout

* User profile

* Status suspend activate

* User roles

* User tokens

* Keys

* SSH key

* All

* Typo

* Fix

* Entitlements

* Groups

* SCIM

* Fix

* Fix

* Clean templates

* Sort API pages

* Fix: HashedSecret

* WIP

* WIP

* WIP

* Fix: cover workspaceagents

* Assert: consistent ID and summary

* Assert: success or failure defined

* Fix: parallel

* Refactor

* Support enterprise

* Go comment goes to top

* Security

* assertPathParametersDefined

* assertUniqueRoutes

* assertRequestBody

* More fixes

* Fix: exceptions

* Fix field format

* Address PR comments

* Refactor
2023-01-13 12:27:21 +01:00
Marcin Tojek 8e9cbdd71b
docs: API users (#5620)
* docs: audit, deploymentconfig, files, parameters

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

* Fix

* WIP

* WIP

* Users

* Logout

* User profile

* Status suspend activate

* User roles

* User tokens

* Keys

* SSH key

* All

* Typo

* Fix

* Fix

* Fix: LoginWithPasswordRequest
2023-01-11 14:08:04 +01:00
Ben Potter 04d45f3c1c
fix!: remove AUTO_IMPORT_TEMPLATE for Kubernetes installs (#5401)
* fix!: remove AUTO_IMPORT_TEMPLATE

* chore: remove template auto importing

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-01-05 04:04:32 +00:00
Steven Masley 27386d49d0
fix: No org admins until organizations are in the UI (#5414)
* fix: No org admins until organizations are in the UI

Until organizations have management UI, we should not set any org
admins. This goes around the site wide perms transparently and
is confusing to users.

Default user is no longer an org admin, so the demotion test makes
no sense
2022-12-14 11:05:42 -06:00
Kyle Carberry fb9ca7b830
feat: Add the option to generate a trial license during setup (#5110)
This allows users to generate a 30 day free license during setup to
test out Enterprise features.
2022-11-16 17:09:49 -06:00
Garrett Delfosse 88f3691dcc
feat: add count to get users endpoint (#5016) 2022-11-14 17:22:57 -05:00
Ammar Bandukwala 97dbd4dc5d
Implement Quotas v3 (#5012)
* provisioner/terraform: add cost to resource_metadata

* provisionerd/runner: use Options struct

* Complete provisionerd implementation

* Add quota_allowance to groups

* Combine Quota and RBAC licenses

* Add Opts to InTx
2022-11-14 17:57:33 +00:00
Presley Pizzo f496b149df
feat: add count endpoint for users, enabling better pagination (#4848)
* Start on backend

* Hook up frontend

* Add to frontend test

* Add go test, wip

* Fix some test bugs

* Fix test

* Format

* Add to authorize.go

* copy user array into local variable

* Authorize route

* Log count error

* Authorize better

* Tweaks to authorization

* More authorization tweaks

* Make gen

* Fix test

Co-authored-by: Garrett <garrett@coder.com>
2022-11-08 10:58:44 -05:00
Jon Ayers 7a5ae1e552
fix: delete all sessions on password change (#4659)
- Prevent users from reusing their old password
  as their new password.
2022-10-19 21:12:03 -05:00
Dean Sheather d898737d6d
feat: app sharing (now open source!) (#4378) 2022-10-15 02:46:38 +10:00
Jon Ayers 3120c94c22
feat: add template RBAC/groups (#4235) 2022-10-10 15:37:06 -05:00
Garrett Delfosse f5df54831a
feat: tokens (#4380) 2022-10-06 19:02:27 +00:00
Steven Masley 587017665a
feat: Also log out of apps if they are hosted on the same domain (#4334)
* feat: Also log out of apps if they are hosted on the same domain

* Update comment
2022-10-04 19:01:16 -04:00
Steven Masley 48c0b59447
fix: Log out of legacy cookie (#4202) 2022-09-26 14:20:38 -04:00
Ammar Bandukwala ee4b934601
Add Users Last Seen At (#4192) 2022-09-26 15:31:03 +00:00
Dean Sheather 6deef06ad2
feat: secure and cross-domain subdomain-based proxying (#4136)
Co-authored-by: Kyle Carberry <kyle@carberry.com>
2022-09-22 22:30:32 +00:00
Colin Adler 5de6f86959
feat: trace httpapi.{Read,Write} (#4134) 2022-09-21 17:07:00 -05:00
Colin Adler 5e2efb68f1
feat: add SCIM provisioning via Okta (#4132)
Co-authored-by: Ben Potter <ben@coder.com>
2022-09-20 15:16:26 -05:00
Kyle Carberry db0ba8588e
chore: Refactor Enterprise code to layer on top of AGPL (#4034)
* chore: Refactor Enterprise code to layer on top of AGPL

This is an experiment to invert the import order of the Enterprise
code to layer on top of AGPL.

* Fix Garrett's comments

* Add pointer.Handle to atomically obtain references

This uses a context to ensure the same value persists through
multiple executions to `Load()`.

* Remove entitlements API from AGPL coderd

* Remove AGPL Coder entitlements endpoint test

* Fix warnings output

* Add command-line flag to toggle audit logging

* Fix hasLicense being set

* Remove features interface

* Fix audit logging default

* Add bash as a dependency

* Add comment

* Add tests for resync and pubsub, and add back previous exp backoff retry

* Separate authz code again

* Add pointer loading example from comment

* Fix duplicate test, remove pointer.Handle

* Fix expired license

* Add entitlements struct

* Fix context passing
2022-09-19 23:11:01 -05:00
Dean Sheather 29d804e692
feat: add API key scopes and application_connect scope (#4067) 2022-09-19 17:39:02 +00:00
Steven Masley 9ab437d6e2
feat: Add serving applications on subdomains and port-based proxying (#3753)
Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-09-14 03:31:33 +10:00
Kyle Carberry 850a83097c
feat: Allow deleting users (#4028)
* Add deleted column to the users table

* Fix user indexes

* Add frontend

* Add test
2022-09-12 23:24:20 +00:00
Colin Adler 4e26e325a6
feat: add auditing to user routes (#3961) 2022-09-08 21:16:16 -05:00
Kyle Carberry 05e2806ff3
feat: Add profile pictures to OAuth users (#3855)
This supports GitHub and OIDC login for profile pictures!
2022-09-04 11:44:27 -05:00
Steven Masley aa9a1c3f56
fix: Prevent suspending owners (#3757) 2022-08-31 15:26:36 +00:00
Dean Sheather 14a9576b77
Auto import kubernetes template in Helm charts (#3550) 2022-08-26 05:32:35 +10:00
Steven Masley 0b53b06fc6
chore: Make member role struct match site roles (#3671) 2022-08-24 15:58:57 -04:00
Spike Curtis c9bce19d88
GET license endpoint (#3651)
* GET license endpoint

Signed-off-by: Spike Curtis <spike@coder.com>

* SDK GetLicenses -> Licenses

Signed-off-by: Spike Curtis <spike@coder.com>

Signed-off-by: Spike Curtis <spike@coder.com>
2022-08-24 18:44:22 +00:00
Jon Ayers a7b49788f5
chore: deduplicate OAuth login code (#3575) 2022-08-22 18:13:46 -05:00
Jon Ayers c3eea98db0
fix: use unique ID for linked accounts (#3441)
- move OAuth-related fields off of api_keys into a new user_links table
- restrict users to single form of login
- process updates to user email/usernames for OIDC
- added a login_type column to users
2022-08-17 18:00:53 -05:00
Steven Masley 01dd35f1ba
chore: Rename 'admin' to 'owner' (#3498)
Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-08-15 14:40:19 -05:00
Steven Masley 3ae42f4de9
chore: Update rego to be partial execution friendly (#3449)
- Improves performance of batch authorization calls
- Enables possibility to convert rego auth calls into SQL WHERE clauses
2022-08-11 22:07:48 +00:00
Steven Masley db665e7261
chore: Drop resource_id support in rbac system (#3426) 2022-08-09 18:16:53 +00:00
Jon Ayers 7e9819f2a8
ref: move httpapi.Reponse into codersdk (#2954) 2022-07-12 19:15:02 -05:00
Steven Masley 576aef40f2
chore: Add linter rule to catch missing return after http writes (#2702) 2022-06-28 14:13:37 -05:00
Colin Adler a494489ffa
fix: use valid ip mask in api keys when remote address is ipv6 (#2695) 2022-06-27 20:31:18 +00:00
Jon Ayers 2353687610
feat: unexpose coderdtest.NewWithAPI (#2613)
* feat: unexpose coderdtest.NewWithAPI
2022-06-27 13:50:52 -05:00
Kyle Carberry 4851d932c4
fix: Split host and port before storing IP (#2594)
The IP was always nil prior, and this fixes the test to
check for that as well!
2022-06-26 21:22:03 +00:00
Abhineet Jain 90815e5119
feat: improve Users filter API (#2645) 2022-06-24 23:55:28 +00:00
Steven Masley d21ab2115d
feat: Backend api for filtering users using filter query string (#2553)
* User search query string
2022-06-24 10:02:23 -05:00
Kyle Carberry b7eeb436ad
feat: Add `ip_address` to API keys (#2580)
Fixes #2561.
2022-06-22 17:32:21 +00:00
Kyle Carberry 4cce969018
feat: Add anonymized telemetry to report product usage (#2273)
* feat: Add anonymized telemetry to report product usage

This adds a background service to report telemetry to a Coder
server for usage data. There will be realtime event data sent
in the future, but for now usage will report on a CRON.

* Fix flake and requested changes

* Add reporting options for setup

* Add reporting for workspaces

* Add resources as they are reported

* Track API key usage

* Ensure telemetry is tracked prior to exit
2022-06-17 00:26:40 -05:00
Steven Masley 251316751e
feat: Return more 404s vs 403s (#2194)
* feat: Return more 404s vs 403s
* Return vague 404 in all cases
2022-06-14 10:14:05 -05:00
Garrett Delfosse 92bda0d2c1
fix: allow admins to reset their own pass without old_password (#2222) 2022-06-10 11:43:54 +10:00
Steven Masley 74fe38eb3d
feat: Add initiator_username to workspace builds in apis (#2174)
* feat: Add initiator_username to workspace builds in apis
2022-06-08 20:23:35 -05:00
Steven Masley af401e3fe1
chore: Linter rule for properly formatted api errors (#2123)
* chore: Linter rule for properly formatted api errors
* Add omitempty to 'Detail' field
2022-06-07 14:33:06 +00:00
Steven Masley c9a4642a12
chore: Update BE http errors to be ui friendly (#1994)
* chore: More UI friendly errors

Mainly capitlization + messages prefix error
2022-06-03 21:48:09 +00:00
Steven Masley 913c0f5e7f
feat: Longer lived api keys for cli (#1935)
* feat: Longer lived api keys for cli
* feat: Refresh tokens based on their lifetime set in the db
* test: Add unit test for refreshing
2022-06-01 14:58:55 -05:00
Steven Masley cc87a0cf6b
feat: Implied 'member' roles for site and organization (#1917)
* feat: Member roles are implied and never exlpicitly added
* Rename "GetAllUserRoles" to "GetAuthorizationRoles"
* feat: Add migration to remove implied roles
* rename user auth role middleware
2022-06-01 09:07:50 -05:00
Steven Masley 7acb742218
feat: Prevent role changing on yourself. (#1931)
* feat: Prevent role changing on yourself.

Only allow changing roles on other users. Not much value in self changing
at the moment
2022-05-31 15:50:38 -05:00
Steven Masley 26a2a169df
fix: Suspended users cannot authenticate (#1849)
* fix: Suspended users cannot authenticate

- Merge roles and apikey extract httpmw
- Add member account to make dev
- feat: UI Shows suspended error logging into suspended account
- change 'active' route to 'activate'
2022-05-31 08:06:42 -05:00
Garrett Delfosse 5598ac05dc
fix: prevent email from being altered (#1863) 2022-05-27 22:25:04 +00:00
Abhineet Jain d623eeb8d1
feat: delete API token in /logout API (#1770)
* delete API token in logout api

* add deleteapikeybyid to databasefake

* set blank cookie on logout always

* refactor logout flow, add unit tests

* update logout messsage

* use read-only file mode for windows

* fix file mode on windows for cleanup

* change file permissions on windows

* assert error is not nil

* refactor cli

* try different file mode on windows

* try different file mode on windows

* try keeping the files open on Windows

* fix the error message on Windows
2022-05-27 16:47:03 -04:00
Garrett Delfosse 24d1a6744a
fix: Add route for user to change own password (#1812) 2022-05-27 17:29:55 +00:00
Steven Masley ec1fe46138
feat: Move create organizations route (#1831)
* feat: last rbac routes
- move create organization to /organizations.
2022-05-27 11:19:13 -05:00
Kyle Carberry 31b819e83f
chore: Remove interface from coderd and lift API surface (#1772)
Abstracting coderd into an interface added misdirection because
the interface was never intended to be fulfilled outside of a single
implementation.

This lifts the abstraction, and attaches all handlers to a root struct
named `*coderd.API`.
2022-05-26 03:14:08 +00:00
Steven Masley eea8dc6c16
feat: Add rbac to templateversion+orgmember endpoints (#1713) 2022-05-25 11:00:59 -05:00
Steven Masley c7ca86d374
feat: Implement RBAC checks on /templates endpoints (#1678)
* feat: Generic Filter method for rbac objects
2022-05-24 08:43:34 -05:00
Steven Masley c034e8389e
feat: Add RBAC to /workspace endpoints (#1566)
* feat: Add RBAC to /workspace endpoints
2022-05-18 18:15:19 -05:00
Garrett Delfosse 0706c60445
chore: Add watch workspace endpoint (#1493) 2022-05-18 16:16:26 -05:00
Steven Masley 4ad5ac2d4a
feat: Rbac more coderd endpoints, unit test to confirm (#1437)
* feat: Enforce authorize call on all endpoints
- Make 'request()' exported for running custom requests
* Rbac users endpoints
* 401 -> 403
2022-05-17 13:43:19 -05:00
Steven Masley b55d83ca82
feat: Add suspend/active user to cli (#1422)
* feat: Add suspend/active user to cli
* UserID is now a string and allows for username too
2022-05-16 15:29:27 -05:00
Colin Adler 680de709a5
chore: organize http handlers (#1486)
They're currently randomly in a bunch of different files. This cleans up
the handler functions to be in the file of the type they return.
2022-05-16 14:36:27 -05:00
Colin Adler 97a95f1377
chore: upgrade golangci-lint to v1.46.0 (#1373) 2022-05-10 16:04:23 -05:00
Mathias Fredriksson 2d3dc436a8
feat: Implement unified pagination and add template versions support (#1308)
* feat: Implement pagination for template versions

* feat: Use unified pagination between users and template versions

* Sync codepaths between users and template versions

* Create requestOption type in codersdk and add test

* Fix created_at edge case for pagination cursor in queries

* feat: Add support for json omitempty and embedded structs in apitypings (#1318)

* Add scripts/apitypings/main.go to Makefile
2022-05-10 07:44:09 +00:00
Kyle Carberry dc115b8ca0
fix: Use proper endpoint for user workspaces (#1356)
This was a silly mistake in a prior PR, so the code wasn't
actually being called!
2022-05-10 03:10:47 +00:00
Kyle Carberry b675aec4dd
feat: Add endpoint to get all workspaces a user can access (#1354)
This iterates through user organizations to get permitted
workspaces. This will allow admins to manage user workspaces!
2022-05-10 02:38:20 +00:00
Bruno Quaresma e54324d880
refactor: Add roles into the user response (#1347) 2022-05-09 16:38:14 +00:00
Bruno Quaresma cf5aca799d
Add reset user password action (#1320) 2022-05-06 13:23:03 -05:00
Bruno Quaresma 57bb108465
feat: Add update user password endpoint (#1310) 2022-05-06 09:20:08 -05:00
Steven Masley 35211e2190
feat: Add user roles, but do not yet enforce them (#1200)
* chore: Rework roles to be expandable by name alone
2022-04-29 09:04:19 -05:00
Bruno Quaresma ba4c3ce3b9
feat: add filter by status on GET /users (#1206) 2022-04-29 08:29:53 -05:00
Colin Adler 1661588bd1
fix: user passwords cleanup (#1202)
1. Adds benchmarks comparing bcrypt and our pbkdf2 settings
1. Changes the pbkdf2 hash iterations back to 65k. 1024 is insecure
1. Gets rid of the short circuit when the user isn't found, preventing
   timing attacks which can reveal which emails exist on a deployment

```
$ go test -bench .
goos: linux
goarch: amd64
pkg: github.com/coder/coder/coderd/userpassword
cpu: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
BenchmarkBcryptMinCost-16        	    1651	    702727 ns/op	    5165 B/op      10 allocs/op
BenchmarkPbkdf2MinCost-16        	    1669	    714843 ns/op	     804 B/op      10 allocs/op
BenchmarkBcryptDefaultCost-16    	      27	  42676316 ns/op	    5246 B/op      10 allocs/op
BenchmarkPbkdf2-16               	      26	  45902236 ns/op	     804 B/op      10 allocs/op
PASS
ok  	github.com/coder/coder/coderd/userpassword	5.036s
```
2022-04-28 18:22:38 +00:00
Bruno Quaresma 816441eff7
feat: add organization_ids in the user(s) response (#1184) 2022-04-28 09:10:17 -05:00
Bruno Quaresma 441ffd6a0b
feat: add PUT /api/v2/users/:user-id/suspend endpoint (#1154) 2022-04-26 09:00:07 -05:00
Kyle Carberry 88669fd578
feat: Move workspaces under organizations (#1109)
This removes split ownership for workspaces. They are now
a resource of organizations and have a designated owner,
which is a user.

This enables simple administration for commands like:
- `coder stop ben/dev`
- `coder build logs colin/arch`

or if we decide to allow administrators to access workspaces,
they could even SSH using this syntax: `coder ssh colin/dev`.
2022-04-25 16:11:03 -05:00
Colin Adler 2a57ea757a
feat: add audit package (#1046) 2022-04-25 18:57:59 +00:00
Kyle Carberry be974cf280
feat: Add users create and list commands (#1111)
This allows for *extremely basic* user management.
2022-04-24 20:08:26 -05:00
Kyle Carberry 7496c3da81
feat: Add GitHub OAuth (#1050)
* Initial oauth

* Add Github authentication

* Add AuthMethods endpoint

* Add frontend

* Rename basic authentication to password

* Add flags for configuring GitHub auth

* Remove name from API keys

* Fix authmethods in test

* Add stories and display auth methods error
2022-04-23 22:58:57 +00:00
Steven Masley 548de7d6f3
feat: User pagination using offsets (#1062)
Offset pagination and cursor pagination supported
2022-04-22 15:27:55 -05:00
Bruno Quaresma 1df750bf1a
feat: add GET /api/v2/users (#1028) 2022-04-18 17:19:47 +00:00
Bruno Quaresma 3311c2f65d
refactor: replace Code by Detail in the http API error (#1011) 2022-04-18 11:02:54 -05:00
Bruno Quaresma 52271ff9f8
fix: use httapi.Write instead of render (#980) 2022-04-12 16:29:07 +00:00
Garrett Delfosse d9d4599ba9
chore: idea: unify http responses further (#941) 2022-04-12 10:17:33 -05:00
Bruno Quaresma 63d1465019
feat: Add update profile endpoint (#916) 2022-04-12 14:05:21 +00:00
Kyle Carberry 02ad3f14f5
chore: Rename Projects to Templates (#880)
Customer feedback indicated projects was a confusing name.
After querying the team internally, it seemed unanimous
that it is indeed a confusing name.

Here's for a lil less confusion @ashmeer7 🥂
2022-04-06 12:42:40 -05:00
Garrett Delfosse 9da17be61e
feat: Add user scoped git ssh keys (#834) 2022-04-06 00:18:26 +00:00
Colin Adler 2b1a0ee126
chore: update v1 schema (#643) 2022-04-01 14:42:36 -05:00
Garrett Delfosse 0d53795c0d
feat: Add strict transport security and secure cookie options (#741) 2022-03-31 12:31:06 -05:00
Steven Masley 591523a078
chore: Move httpapi, httpmw, & database into `coderd` (#568)
* chore: Move httpmw to /coderd directory
httpmw is specific to coderd and should be scoped under coderd

* chore: Move httpapi to /coderd directory
httpapi is specific to coderd and should be scoped under coderd

* chore: Move database  to /coderd directory
database is specific to coderd and should be scoped under coderd

* chore: Update codecov & gitattributes for generated files
* chore: Update Makefile
2022-03-25 16:07:45 -05:00
Kyle Carberry c451f4e685
feat: Add templates to create working release (#422)
* Add templates

* Move API structs to codersdk

* Back to green tests!

* It all works, but now with tea! 🧋

* It works!

* Add cancellation to provisionerd

* Tests pass!

* Add deletion of workspaces and projects

* Fix agent lock

* Add clog

* Fix linting errors

* Remove unused CLI tests

* Rename daemon to start

* Fix leaking command

* Fix promptui test

* Update agent connection frequency

* Skip login tests on Windows

* Increase tunnel connect timeout

* Fix templater

* Lower test requirements

* Fix embed

* Disable promptui tests for Windows

* Fix write newline

* Fix PTY write newline

* Fix CloseReader

* Fix compilation on Windows

* Fix linting error

* Remove bubbletea

* Cleanup readwriter

* Use embedded templates instead of serving over API

* Move templates to examples

* Improve workspace create flow

* Fix Windows build

* Fix tests

* Fix linting errors

* Fix untar with extracting max size

* Fix newline char
2022-03-22 13:17:50 -06:00
Kyle Carberry bf0ae8f573
feat: Refactor API routes to use UUIDs instead of friendly names (#401)
* Add client for agent

* Cleanup code

* Fix linting error

* Rename routes to be simpler

* Rename workspace history to workspace build

* Refactor HTTP middlewares to use UUIDs

* Cleanup routes

* Compiles!

* Fix files and organizations

* Fix querying

* Fix agent lock

* Cleanup database abstraction

* Add parameters

* Fix linting errors

* Fix log race

* Lock on close wait

* Fix log cleanup

* Fix e2e tests

* Fix upstream version of opencensus-go

* Update coderdtest.go

* Fix coverpkg

* Fix codecov ignore
2022-03-07 11:40:54 -06:00
Bryan 3f7781403d
feat: Login via CLI (#298)
Fixes #210 - this isPR implements `coder login` in the case where the default user is already created.

This change adds:
- A prompt in the case where there is not an initial user that opens the server URL + requests a session token
  - This ports over some code from v1 for the `openURL` and `isWSL` functions to support opening the browser
- A `/api/v2/api-keys` endpoint that can be `POST`'d to in order to request a new api key for a user
  - This route was inspired by the v1 functionality
- A `cli-auth` route + page that shows the generated api key
- Tests for the new code + storybook for the new UI

The `/cli-auth` route, like in v1, is very minimal:

<img width="624" alt="Screen Shot 2022-02-16 at 5 05 07 PM" src="https://user-images.githubusercontent.com/88213859/154384627-78ab9841-27bf-490f-9bbe-23f8173c9e97.png">

And the terminal UX looks like this:

![2022-02-16 17 13 29](https://user-images.githubusercontent.com/88213859/154385225-509c78d7-840c-4cab-8f1e-074fede8f97e.gif)
2022-02-17 20:09:33 -08:00
Kyle Carberry 07fe5ced68
feat: Add "coder" CLI (#221)
* feat: Add "coder" CLI

* Add CLI test for login

* Add "bin/coder" target to Makefile

* Update promptui to fix race

* Fix error scope

* Don't run CLI tests on Windows

* Fix requested changes
2022-02-10 08:33:27 -06:00
Kyle Carberry 1796dc6c2f
chore: Add test helpers to improve coverage (#166)
* chore: Rename ProjectHistory to ProjectVersion

Version more accurately represents version storage. This
forks from the WorkspaceHistory name, but I think it's
easier to understand Workspace history.

* Rename files

* Standardize tests a bit more

* Remove Server struct from coderdtest

* Improve test coverage for workspace history

* Fix linting errors

* Fix coderd test leak

* Fix coderd test leak

* Improve workspace history logs

* Standardize test structure for codersdk

* Fix linting errors

* Fix WebSocket compression

* Update coderd/workspaces.go

Co-authored-by: Bryan <bryan@coder.com>

* Add test for listing project parameters

* Cache npm dependencies with setup node

* Remove windows npm cache key

Co-authored-by: Bryan <bryan@coder.com>
2022-02-05 18:24:51 -06:00
Kyle Carberry 177eba87b6
refactor: Move all HTTP routes to top-level struct (#130)
* feat: Add history middleware parameters

These will be used for streaming logs, checking status,
and other operations related to workspace and project
history.

* refactor: Move all HTTP routes to top-level struct

Nesting all structs behind their respective structures
is leaky, and promotes naming conflicts between handlers.

Our HTTP routes cannot have conflicts, so neither should
function naming.
2022-02-01 22:15:26 +00:00
Kyle Carberry 5b01f615eb
feat: Add APIs for querying workspaces (#61)
* Add SQL migration

* Add query functions for workspaces

* Add create routes

* Add tests for codersdk

* Add workspace parameter route

* Add workspace query

* Move workspace function

* Add querying for workspace history

* Fix query

* Fix syntax error

* Move workspace routes

* Fix version

* Add CLI tests

* Fix syntax error

* Remove error

* Fix history error

* Add new user test

* Fix test

* Lower target to 70%

* Improve comments

* Add comment
2022-01-25 19:52:58 +00:00