Commit Graph

52 Commits

Author SHA1 Message Date
Filipe Pina
bcbb2e9f6e linting: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (golint) 2022-07-07 07:49:17 +01:00
Anders Pitman
ebf114e182 Fix bug when creating client tokens
It was using the user that made the request as the user to get
the list of clients from, which meant for example if an admin made
the request, you were limited to the names of clients that the
admin also used.
2022-03-09 12:19:44 -07:00
Anders Pitman
5d1be78478 Implement GET for /api/users and /api/tokens 2022-03-04 11:45:36 -07:00
Anders Pitman
dcb06497ad Implement overriding SSH server per tunnel
This lets you use a proxy for connecting to the SSH server, which
is useful on networks that block SSH/port 22. For example you can
use the boringproxy tuntls command to create a proxy that will
tunnel the client's SSH connections over TLS to the server.

It's all very meta and forces at least double encryption, but it
could be useful.
2022-02-24 14:33:13 -07:00
Anders Pitman
197e202d69 Implement raw server TLS tunnels
Also cleaned up things a bit by moving the ProxyTcp logic into
a separate file and sharing it between the client and server.
2022-02-24 14:12:09 -07:00
Anders Pitman
72185f454c Remove deprecated /api/users/<user>/clients 2022-02-17 14:55:14 -07:00
Anders Pitman
691afe1f8f Implement /api/clients DELETE and fix bug
Wasn't properly using user param.
2022-02-17 14:52:54 -07:00
Anders Pitman
0eab8db4d6 Simplify client creation API
Previously it was RESTful and required both a user and client
name in order to PUT new clients. Now this information is taken
from the token if possible (user is always available, client name
may not be) and a simple POST /clients endpoint is provided.
2022-02-17 14:40:17 -07:00
Anders Pitman
5ae2b81882 Fix login token bug
When creating a login token, need to make sure client is set
blank when stored in the DB.
2022-02-17 11:37:02 -07:00
Anders Pitman
0b9a175ce9 Check client when creating client on api 2022-02-16 12:58:26 -07:00
Anders Pitman
5ff2250a59 Allow scoped tokens to create clients 2022-02-16 11:58:34 -07:00
Anders Pitman
0a23c2fc0e Limit token permissions
Added the ability to scope tokens to a specific client. If
enabled, this has the affect of limiting the token to being used
to list tunnels for that specific client. It can't be used for
the web UI or for any state-changing actions such as creating
new tunnels.
2022-02-16 11:44:24 -07:00
Anders Pitman
3be1f0b48c Implement raw TLS tunnels
My testing shows this works for WebSockets.
2022-02-11 13:04:59 -07:00
Anders Pitman
b795ee0bc9 Remove unused custom SSH key code
Was originally planning to allow people to upload public keys to
use for tunnels, but so far no one has asked for this and I
haven't needed it.
2021-12-21 13:14:01 -07:00
Anders Pitman
2b74f6ee0c Implement selecting tunnel port
This is useful for when you want to use boringproxy more like a
normal reverse proxy, ie if boringproxy and your service are on
the same machine, you can just use the port of the service as the
tunnel port and boringproxy will forward directly to it without
using SSH.

This would normally be used with no client set.
2021-02-16 18:37:31 -07:00
Anders Pitman
8753c11f57 Fix invalid method HTTP error code
Fixes #54
2021-02-15 11:50:27 -07:00
Anders Pitman
8e743ad304 Properly set owner on tunnel creation 2021-01-22 22:03:57 -07:00
Anders Pitman
e09a7d91df Override tunnel SSH server ports at runtime
This is a bit of a hack. Problem is if the server is restarted
with a different SSH port, all the tunnels in the db have the
incorrect port setting, so we're overriding at runtime.

Really should update all the db entries but that's messy too.

Probably the real solution is to decouple runtime tunnel settings
from permanent tunnel settings, and only store the permanent ones
in the db.
2021-01-13 10:22:19 -07:00
Anders Pitman
20f7d53c0f Rename instances of BoringProxy
Full name isn't necessary now that it's a library.

BoringProxy -> Server
BoringProxyClient -> Client
BoringProxyConfig -> Config
2020-12-07 21:50:33 -07:00
Anders Pitman
45f609b8ba Move executable into separate package
Enables us to move towards being able to import as a library.
2020-12-07 21:41:45 -07:00
Anders Pitman
c08671bd13 Implement setting TlsTermination on server 2020-11-27 16:01:40 -07:00
Anders Pitman
98a6ff52fc Delete tokens when user is deleted
Also added DeleteUser to API
2020-10-30 18:50:24 -06:00
Anders Pitman
27aeb57336 Clean up api code organization 2020-10-30 18:38:57 -06:00
Anders Pitman
6b9f9aa413 Implement creating users and tokens from REST API 2020-10-29 17:56:38 -06:00
Anders Pitman
4fd830167f Fix more security holes 2020-10-27 15:21:56 -06:00
Anders Pitman
51dce1876d Fix token delete security bug 2020-10-27 14:48:22 -06:00
Anders Pitman
f6fee2b8c0 Check permissions for deleting tunnels 2020-10-27 14:39:44 -06:00
Anders Pitman
b3f1636be6 Fix some security issues
* The CSS styles were leaking information about tunnels, even for
  things like the login page, which can be sent to anyone.
* Tokens could be created for any user by any user.
2020-10-26 12:18:51 -06:00
Anders Pitman
1abc141d13 Make client selection a dropdown
Also implemented adding and deleting clients through the API.
2020-10-24 16:48:53 -06:00
Anders Pitman
1607d41e5c Add button for downloading private keys
Allows users to access tunnels using standard SSH clients.
2020-10-24 14:12:18 -06:00
Anders Pitman
8477391273 Implement using custom SSH keys 2020-10-23 20:56:55 -06:00
Anders Pitman
fd0451fa3b Implement password-protected tunnels 2020-10-20 20:03:59 -06:00
Anders Pitman
85a5004cc7 Implement raw TCP tunnels
Just needed to add an option to allow external connections to the
ports from the server, then set the proper values in the
authorized_keys file and on the client.
2020-10-20 19:14:04 -06:00
Anders Pitman
9882017d5a Add ClientAddress
Allows tunnels to specify what address the client with connect to
for upstream connections.

Also changed the tunnel-adder UI.

Also fixed a bug where invalid domains would crash. Needed to
properly return an error dialog.
2020-10-20 18:52:32 -06:00
Anders Pitman
770440ef79 Handle DeleteTunnel for UI in API 2020-10-14 10:42:54 -06:00
Anders Pitman
b0c888221d Clean up CreateTunnel error handling 2020-10-14 10:33:06 -06:00
Anders Pitman
fb8d379663 Create UI tunnels through API 2020-10-14 10:29:19 -06:00
Anders Pitman
cfcd781276 Filter UI requests through API
API is now the central control point for making authorized
requests. The current architecture is:

* db simply returns all data
* api uses tokens to filter data from db. It includes methods for
  returning objects, and HTTP endpoints for return JSON.
* ui calls the api functions to get filtered data.
2020-10-14 09:17:04 -06:00
Anders Pitman
85d67e262a Do more authorization checking
Limit certain information based on user and whether they're an
admin.
2020-10-13 11:21:42 -06:00
Anders Pitman
1e25527ab2 Rename sessions to tokens/tokenData 2020-10-11 14:27:32 -06:00
Anders Pitman
41bd4759eb Add ETag hash to tunnel responses 2020-10-10 08:20:17 -06:00
Anders Pitman
ffc0d27338 Start implementing remote-controlled clients 2020-10-09 10:05:31 -06:00
Anders Pitman
6c2db42c2a Store full tunnel information in db
Now have a single Tunnel type which is returned on creation and
when querying the current tunnels.
2020-10-08 12:51:52 -06:00
Anders Pitman
f234049877 Add X-Forwarded-Host header to upstream requests 2020-10-07 09:18:04 -06:00
Anders Pitman
03baac2c7b Implement tunnel delete for /api 2020-10-06 19:00:20 -06:00
Anders Pitman
57e2e80ed4 Reuse httpClient 2020-10-06 10:22:03 -06:00
Anders Pitman
6ee5a5d3f4 Move /tunnels GET to /api 2020-10-05 23:37:03 -06:00
Anders Pitman
5b5f474853 Move sessions and tunnels into database 2020-10-05 23:25:36 -06:00
Anders Pitman
f712499773 Get username and home dir from system 2020-10-03 20:40:14 -06:00
Anders Pitman
c285f0990f Run go fmt 2020-10-02 17:09:14 -06:00