Commit Graph
121 Commits
Author SHA1 Message Date
Emil NikolovandDave Anderson b75983b637 service: explicitly depend on network-online.target
Signed-off-by: Emil Nikolov <emil.e.nikolov@gmail.com>
2024-01-20 23:22:21 -08:00
M. J. FrombergerandGitHub 5ee5a81391 go.mod: update tailscale.com to commit ca48db0d606d (#106)
Updates #96

Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
2024-01-11 08:37:35 -08:00
M. J. FrombergerandGitHub 4d96c55246 go.mod: update tailscale.com to v1.56.1 (#105)
Previous versions flag a potential security fix in the admin panel.

Updates #96

Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
2024-01-11 07:58:06 -08:00
Patrick O'DohertyandGitHub 311ede68ef golink: check for CertDomains before enabling HTTPS (#103)
Fixes https://github.com/tailscale/golink/issues/102

Ensure that we have CertDomains for the HTTPS listener before asking
tsnet to create one.

Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2023-12-20 09:59:06 -08:00
Patrick O'DohertyandGitHub 3f822b66e7 golink: listen on HTTPS and redirect HTTP traffic (#99)
golink: listen on HTTPS and redirect HTTP traffic

Updates tailscale/golink#9
Fixes tailscale/golink#29

On tailnets with HTTPS enabled golink will serve the primary endpoints via
HTTPS. With HTTPS enabled golink will respond to HTTP traffic with a 
separate redirectHandler which redirects requests to their HTTPS equivalent.

Update documented examples of `curl` to include the `-L` flog to follow these
redirects if present. 

Add a HTTPS section to the README documenting all of the above.

Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2023-12-18 14:14:52 -08:00
Will NorrisandWill Norris 0abea01a93 golink: align on tailscale.com/cap naming convention
Signed-off-by: Will Norris <will@tailscale.com>
2023-12-13 09:09:57 -08:00
Will NorrisandWill Norris c9212a47de .github: update actions in docker workflow
Signed-off-by: Will Norris <will@tailscale.com>
2023-11-15 08:26:40 -08:00
Will NorrisandWill Norris c4bacfd78c .github: run yaml files through prettier
Signed-off-by: Will Norris <will@tailscale.com>
2023-11-15 08:26:40 -08:00
Will NorrisandWill Norris 7f89e2e42c golink: set HTTP status after Location header
I didn't think the order mattered (as long as none of the response body
had been written), but I guess I was wrong. Currently, it's returning
the 302 status, but no Location header. And tests, at least some of
which should be passing through this full code path, are passing. I'll
look into adding better testing later, but for now this fixes the
immediate issue.

Updates #91

Signed-off-by: Will Norris <will@tailscale.com>
2023-11-14 21:42:41 -08:00
Will NorrisandWill Norris 7db43e2d37 golink: use new serveHandler with tsnet
In 46ed42f, I mistakenly only attached the serveHandler to the dev
listener, but not tsnet.

Fixes #91

Signed-off-by: Will Norris <will@tailscale.com>
2023-11-14 20:18:12 -08:00
Will NorrisandWill Norris 46ed42fc5d golink: don't modify URL path when resolving link
Both http.ServeMux as well as the http.Redirect method pass the request
URL through `cleanPath` which, among other things, collapses double
slashes `//` to a single slash `/`. Most of the time this is fine, since
most servers treat those as identical anyway. But some destination
servers need the original path unmodified. Since we're just redirecting,
we don't need to be concerned with the additional benefits of
`cleanPath` such as eliminating `../` path components, since that is the
responsibility of the destination server to clean if needed.

This change adds a separate root http.Handler for golink requests. It
still uses http.ServeMux for internal endpoints, but serves golinks
directly without passing the request through ServeMux. Additionally,
this sets the redirect status and Location header directly rather than
calling http.Redirect, since that also modifies the URL it is given.

Fixes #89

Signed-off-by: Will Norris <will@tailscale.com>
2023-11-14 08:38:17 -08:00
Will NorrisandWill Norris 2ff7d040f8 add support for golink peer capability
The "tailscale.com/golink" peercap includes a single "admin" bool field.
When set, this grants the user the ability to edit all links stored in
the system.

Update currentUser to return a simple user struct instead of just a bare
username. Rename checkLinkOwnership to canEditLink and change to a bool
return value.

Signed-off-by: Will Norris <will@tailscale.com>
2023-10-30 20:29:58 -07:00
Will NorrisandWill Norris 97cee318a6 go.mod: bump to tailscale 1.52.0
Technically, this is one commit before the 1.52.0 tag to keep it a
pseudo-version.

Signed-off-by: Will Norris <will@tailscale.com>
2023-10-30 20:29:58 -07:00
Will NorrisandWill Norris 3d62a353ac Dockerfile: stop using chainguard go image
Chainguard is no longer allowing free users to use specific versions of
images like go (instead, having to always use "latest"). So instead, we
will create our own build image by installing the needed packages on top
of the wolfi-base image.

This is one of the recommended approaches in their migration guide:
https://www.chainguard.dev/unchained/a-guide-on-how-to-use-chainguard-images-for-public-catalog-tier-users

Fixes #82

Signed-off-by: Will Norris <will@tailscale.com>
2023-07-14 12:17:24 -07:00
Marco HofstetterandWill Norris 843e615dbf remove unused disabled input fields in form
The detail page of a link only displays the form if the link is editable
for the logged in user.

Therefore, it's not necessary to disable the input fields within the
form if the link isn't editable.

Signed-off-by: Marco Hofstetter <marco.hofstetter@bluewin.ch>
2023-06-26 08:13:54 -07:00
Marco HofstetterandWill Norris e6a9c75f4f support tagged-devices in userExists in devmode
Even in dev mode, the user `tagged-devices` should not be
reported as existing user.

This allows editing & deleting links owned by `taggged-devices`
in dev mode.

Signed-off-by: Marco Hofstetter <marco.hofstetter@bluewin.ch>
2023-06-21 17:36:56 -07:00
Marco HofstetterandWill Norris 2b98aed2ea allow deletion of unowned links
It should be possible to delete links owned by non-existing users
(tagged-devices or deleted) in the same ways as it's possible
to edit these links.

Signed-off-by: Marco Hofstetter <marco.hofstetter@bluewin.ch>
2023-06-21 17:36:56 -07:00
Will NorrisandWill Norris a762273463 retain query string from original request
When resolving a go link, combine the query string parameters from the
request and long URL.

Updates #77

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-16 10:17:35 -07:00
Will NorrisandWill Norris ae5d8c9b6c pass url.URL rather than string
return a *url.URL value from expandLink rather than a string, and both
accept and return a *url.URL value from resolveLink rather than a
string. These are both unexported funcs, so this has no changes to the
current behavior. It does prevent a few unnecessary conversions back and
forth between url.URL and string values, and will make it simpler to
retain request query strings.

Updates #77

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-16 10:17:35 -07:00
Will NorrisandWill Norris f00de63b45 parse link short name just from request path
Previously, we were parsing from r.RequestURI, which includes both the
path and query string.  This causes problem for requests like go/who?q
which try to lookup a link named "who?q" rather than "who" (see #77).

For now, this just ignores the request query string. Eventually we
should probably retain the query string, but this begins by parsing out
the short name properly.

Updates #77

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-16 10:17:35 -07:00
Kristoffer DalbyandWill Norris 3ec5bd9693 nix: update nix dependencies
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2023-05-02 11:40:12 -07:00
Kristoffer DalbyandWill Norris 3eb57635ae nix: update flake hash to mirror go.mod
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2023-05-02 11:40:12 -07:00
Will NorrisandWill Norris 41060ba068 go.mod: bump tailscale.com version
bump version again, back to the latest commit on main, rather than the
latest released version. Otherwise, this causes issues in tailscale's
corp repo (sadly).

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 21:01:05 -07:00
Will NorrisandWill Norris ec2a3e94c6 go.mod: bump tailscale.com version
Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 20:55:34 -07:00
Will NorrisandWill Norris 61a86749e3 allow links to be saved without known owner
If the current user can't be determined (either because of a legitimate
error within the localapi client, or the user is coming through a subnet
router and doesn't have a Tailscale IP address), and the
-allow-unknown-users flag is set, then go ahead and save new links
without an owner.

By saving links without an owner, these unknown users can continue to
modify the link, and actual Tailscale users can take ownership. Once the
link is owned, it can no longer be modified by anyone other than the
owner.

Links that use the current user by having `{{ .User }}` in their long
URL cannot be resolved by unknown users and will return an error.

Fixes #60

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 20:55:34 -07:00
c7ac33d04c golink: add support for deleting links
To delete a link, go to its page in `.detail` and click on the "Delete"
button. Stats for the deleted link are removed as well.

Co-authored-by: Will Norris <will@tailscale.com>
Signed-off-by: Gabriel Wong <gabriel@bifrost.ai>
Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 17:34:41 -07:00
Will NorrisandWill Norris 132a396390 update colors and tweak detail layout
Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 17:34:41 -07:00
Will NorrisandWill Norris 31b1ce1ac1 add tests for serve methods
Also check error returned from tmpl.Execute. Refactor currentUser to
make the logic a little simpler, and make it a package var for easier
testing.

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 12:22:42 -07:00
Will NorrisandWill Norris b9fdc2dcab golink: allow -resolve-from-backup to resolve alias links
It's not uncommon to have multiple links pointing to the same
destination, for example to handle different spellings of a word or
because different people created them at different times.

A common best practice is to select one as the "primary" link and point
the others to that link as "aliases".  This change updates resolveLink
to follow those aliases so that the final destination is returned when
using `golink -resolve-from-backup`.

Signed-off-by: Will Norris <will@tailscale.com>
2023-03-29 13:55:38 -07:00
Maisem AliandGitHub 7fa6e009f6 golink: set hostinfo.Package to "golink" (#64)
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-02-28 15:51:38 -08:00
Maisem AliandGitHub acd564144f go.mod: bump tailscale.com from main (#67)
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-02-28 15:44:50 -08:00
Kristoffer DalbyandGitHub 9bf1f0a11e nix: update go to 1.20 in flake.nix (#66) 2023-02-28 18:39:06 +01:00
Kristoffer DalbyandGitHub d0a6324e2f nix: add script to update flake vendor hash (#65) 2023-02-28 18:35:14 +01:00
Felix HeilmeyerandWill Norris 0d1e616fe9 db: add mutex to fix http errors during stats save
Signed-off-by: Felix Heilmeyer <code@fehe.eu>
2023-02-12 20:00:51 -08:00
Will NorrisandWill Norris 7fd2d35ba6 include current user resolving link in expandEnv
Add "User" to the expansion environment for links.  The intent here it
support personalized go links such as:

go/mycal => https://calendar.google.com/calendar/embed?src={{.User}}

That's not a terribly interesting example, but there are others I intend
to use internally.

Signed-off-by: Will Norris <will@tailscale.com>
2023-02-08 16:24:36 -08:00
Will NorrisandWill Norris 9c46bb3412 stats: return early if no stats to write
Signed-off-by: Will Norris <will@tailscale.com>
2023-02-08 14:51:00 -08:00
Will NorrisandWill Norris 3c4fb78866 css: responsive design for /.all page
Signed-off-by: Will Norris <will@tailscale.com>
2023-02-07 16:08:19 -08:00
Gabriel WongandWill Norris 340adb143b golink: add .all page to display all existing links
Signed-off-by: Gabriel Wong <gabriel@bifrost.ai>
2023-02-07 16:08:19 -08:00
Gabriel WongandWill Norris 789e2a8a67 readme: update fly.toml volume mount
PR #12 changes directory used by Docker image. This commit updates the fly.io
instructions to use the same directory.

Signed-off-by: Gabriel Wong <gabriel@bifrost.ai>
2023-02-07 11:32:15 -08:00
Will NorrisandWill Norris 396a3ae5a9 .github/workflow: use buildx v0.9.1 to fix fly deploys
Fixes #51

Signed-off-by: Will Norris <will@tailscale.com>
2023-02-01 13:20:01 -08:00
136d5ad3ec Add Flake file (Nix package, NixOS module) (#39)
* Add Flake file (Nix package, NixOS module)

This commit adds a Flake.nix file allowing Nix users to consume this
repo with `nix build`, `nix run` and adds a NixOS module to quickly spin
up the service.

* add github action file for nix build

---------
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Co-authored-by: Xe Iaso <me@xeiaso.net>
2023-01-27 16:19:41 +01:00
Manuel CoppotelliandWill Norris cada6f65af add control url flag
Signed-off-by: Manuel Coppotelli <hi@manuel.coppotelli.me>
2023-01-12 16:43:20 -08:00
Filippo ValsordaandWill Norris fbc6650c5f readme: fixup Firefox instructions 2023-01-12 07:52:00 -08:00
Filippo ValsordaandWill Norris 80c84d264b readme: add Firefox instructions 2023-01-12 06:32:33 -08:00
Will NorrisandWill Norris 3af59c51b8 Dockerfile: cross compile images using native builder
Use a build image built for the native architecture so that it doesn't
run in emulation mode.

Switch to Chainguard's wolfi/glibc build image. This limits our build
architectures to just amd64 and arm64, but that is sufficient for our
needs.

Updates #42
Updates #43

Signed-off-by: Will Norris <will@tailscale.com>
2023-01-09 20:32:47 -08:00
Will NorrisandWill Norris ef7f8b26d8 Dockerfile: use musl variant for go build image
Fixes #42

Signed-off-by: Will Norris <will@tailscale.com>
2023-01-07 10:42:53 -08:00
Simon HaywardandWill Norris e257a3cf27 UserExists check looks to be on the owner
Updates the log msg to use owner.

Signed-off-by: Simon Hayward <simonhayward@users.noreply.github.com>
2022-12-29 11:24:30 -08:00
Will NorrisandWill Norris 406c48e54d skip "tagged-devices" in userExists check
Currently, the special "tagged-devices" user (which exists for any
tagged devices in the tailnet) can own go links.  This change permits
tagged devices to continue to create go links, but skips over them for
ownership checks, allowing any human user can take over ownership.

Fixes #37

Signed-off-by: Will Norris <will@tailscale.com>
2022-12-22 12:15:49 -08:00
Samuel LijinandWill Norris 442e3446a5 fix(readme): another typo 2022-12-21 12:48:49 -08:00
Will NorrisandWill Norris b6f2ad4476 db: use canonical link short name in stats
When loading stats from the database, map IDs back to their canonical
short name, which is what we want to show in the frontend.  This is only
called once on cold start, so performance of loading all links isn't a
big concern.

Fixes #13

Signed-off-by: Will Norris <will@tailscale.com>
2022-12-21 10:52:23 -08:00