Commit Graph
52 Commits
Author SHA1 Message Date
STeve (Xin) Huang 3a0ab15f4a Support App access behind load balancer (#22565)
* Support App access behind load balancer

* revert unecessary change

* fix lint

* Fix UT

* minor refactor
2023-03-14 13:47:41 +00:00
rosstimothy 95d6d0fee1 Migrate GetCertAuthority to gRPC (#22624)
The HTTP client created by `auth.NewClient` has an idle timeout of
30s and each instance periodically gets cert authorities in
`TeleportProcess.syncRotationStateCycle`. If there has been no
activity when the ticker expires then the request will result in a
brand new connection to Auth to be established. This can cause a
spikes in open file descriptors on the Proxy when there are a large
number of instances connected via a tunnel.

To prevent periodic dialing when retrieving cert authorities the
endpoint has been migrated to the new Trust gRPC service. For now
only the get endpoint has been migrated but the rest of the CRUD
operations for cert authorities should be migrated from the HTTP
api to the gRPC service as well.
2023-03-10 14:32:34 +00:00
Anton Miniailo 3633c6181e Add secure client IP propagation throughout teleport (#21080) 2023-02-28 20:38:12 +00:00
Krzysztof Skrzętnicki 20d4c79812 App access: rewrite redirects to public app address from leaf cluster. (#21067)
Fixes #8112.
2023-02-17 13:35:23 +00:00
Zac Bergquist c924be5c6d Refer to tsh apps subcommand (#21431)
The `tsh appps` family of commands is aliased to `tsh apps`, so both
invocations work correctly. The command itself is defined as `tsh apps`,
so this is what appears in the help message.

Update references to `tsh app` to recommend `tsh apps` instead so that
there isn't confusion when browsing `tsh help` and looking for a missing
`app` subcommand.

Fixes #21367
2023-02-10 21:40:55 +00:00
Gabriel CoradoandRafał Cieślak bc63dddd7b Verify if proxy can handle application requests when creating session (#20418)
* feat(app): ensure there are healthy app services when creating session

* Apply suggestions from code review

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>

* chore: code review updates

* refactor(app): preflight connection before creating session

* chore(web): change error message

* reafactor(app): change redirect to launcher rule

* refactor(app): rename preflight connection to health check app server

* refactor(apiserver): rename preflight connection

* refactor(apiserver): rename preflight connection

* refactor(apiserver): remove health check property

* test(appaccess): adjust new http status codes returned

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2023-02-10 10:42:55 +00:00
Ryan Clark f47e265c86 Use SameSiteNoneMode for application access cookies (#21012) 2023-01-31 21:53:45 +00:00
Ryan ClarkandZac Bergquist f2fbe92dcb Change the application access authentication flow (#17592)
* Change the application access auth flow to use a CORS POST request

* Remove auth state cookie

* Close the response body in tests

* Change the CSP to allow cross origin requests to the application

* Change the cookies to lax mode

* Update lib/web/app/handler_test.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* Fix the proxy URL in tests

* Update webassets ref

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2023-01-12 21:57:01 +00:00
Alan Parra ba1282df62 Improve UserMetadata audit logging (#20081)
Improve UserMetadata audit logging by using `tlsca.Identity.GetUserMetadata()`
more consistently in audit logs.

There are still a handful of logs that don't include the data above for lack of
context (in the general sense and in the Go context sense), but many more
entries now call back to identity in some way.

Related to gravitational/teleport.e#514.
2023-01-11 21:03:17 +00:00
Gavin Frazar 4330e43cc9 security: Prevent app access authz bypass 2022-12-28 09:24:02 -08:00
Steven Martin e1ebc332f8 spell fixes (#19419) 2022-12-16 19:01:28 +00:00
Mike Jensen 8c1e7be02d Security Response Header Uniformity Improvements (#18951)
Our need for customizing our security response headers primarily exists with the Content-Security-Policy.  Other headers can be applied more broadly to provide safe defaults across our service.

This commit changes httpheaders.go to allow for the CSP to be applied separate from the other headers.  Then the changes to httplib.go's handlers help make sure these headers are set generally (which we were already partially doing for caching directives).

Other changes were primarily making sure these tools are configured or used.  Or a removal of previous settings as this function is now being handled more centrally.
2022-12-06 00:56:59 +00:00
Zac Bergquist da7680ad0b Use x/exp/slices instead of home grown utilities (#18524)
We were inconsistent throughout the codebase and would sometimes
use the slices package and other times use our own equivalents
in api/.

This removes our versions in favor of the golang.org/x package that
does the same, which has the added benefit of reducing the surface
area of the public API module.

Note: despite existing uses of the slices package, for some reason
it didn't show up in go.mod or go.sum. Fixed that too.
2022-11-17 15:25:46 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
756eb91ede Add X-Forwarded-SSL and X-Forwarded-Port to appaccess. (#16965)
* Add X-Forwarded-SSL and X-Forwarded-Port to appaccess.

Application Access now adds in X-Forwarded-Ssl and X-Forwarded-Port headers.
Tests have been added and adjusted to look for these new headers as well.

* Update lib/srv/app/header_rewriter.go

Co-authored-by: Ryan Clark <ryan.clark@goteleport.com>

* Update integration/appaccess/fixtures.go

Co-authored-by: Roman Tkachenko <roman@goteleport.com>

* Remove common.XForwardedPort

* Change order of websocket delegates.

* Make ReservedHeaders more future-proofed.
2022-10-12 16:54:53 +00:00
Michael b4bfd0b719 moved redirect path param to RawQuery and added escaping (#15628)
* moved redirect path param to RawQuery and added escaping

* fixed test description
2022-08-29 11:23:21 -05:00
Roman Tkachenko 38b8bb4307 Add support for proxying TCP apps (#13455)
Add support for proxying tcp apps
2022-07-26 19:01:39 +00:00
Michael f5d9b32857 only build url if path param exists (#14388)
* only build url if path param exists

* updated comment
2022-07-12 13:43:14 -05:00
Michael 4280f814ae pass and preserve a path parameter during the app authentication (#13832)
* pass and preserve a path parameter during the app access authentication process

* added missing semicolons

* more javascript formatting

* removed incorrect path redirect. replace URL with URL.Path

* added a test for HasName

* added another test for default path

* ensure path param is valid path

* build url without string concat
2022-06-30 19:49:46 -05:00
David Boslee 32695a2f05 Add proxy peering support (#12359)
This adds proxy peering support. A configurable setting that allows for agents 
to connect to a subset of proxies and be reachable through any proxy in the
cluster. This is achieved by creating grpc connections between each proxy
server. Client connections can then be passed between proxies to the desired
agent.
2022-06-02 17:08:24 +00:00
Gabriel Corado be760bbe60 Dial only application servers that serve the requested application (#12217)
* feat(reversetunnel): add a dial counter on fake remote site

* refactor(app): change `MatchHealthy` to close connections

* refactor(app): change `MatchAll` order to not dial all servers

* refactor(app): only close connection when dial succeeds
2022-04-28 16:09:43 +00:00
Krzysztof SkrzętnickiandPrzemko Robakowski 66a676eb73 Switch to forked httprouter and enable UseRawPath option (#11068)
* Use forked httprouter with RawPath fix: gravitational/httprouter

* Enable UseRawPath everywhere.

* Test: allow MFA devices with `/` in names to be deleted

Co-authored-by: Przemko Robakowski <przemko.robakowski@goteleport.com>
2022-04-19 07:16:54 +00:00
rosstimothy 550d23d15d Fix goroutine and memory leak in watchCertAuthorities (#10871)
* Fix goroutine and memory leak in watchCertAuthorities

The CA Watcher was blocking both on writing to a channel when the watcher
was closed and on HTTP calls that had no request timeout or context passed
to cause cancellation.

All resourceWatcher implementations that had a bug which may cause them to block
on writing to a channel forever were fixed by selecting on the write and ctx.Done.

Adding context.Context to all Get/Put/Post/Delete methods on the auth HTTPClient to
force callers to propagate context. Prior all calls used context.TODO which
prevents requests from being properly cancelled.

Add context propagation to RotateCertAuthority, RotateExternalCertAuthority,
GetCertAuthority, GetCertAuthorities. This is needed to get the correct ctx
from the CertAtuhorityWatcher all the way down to the HTTPClient that makes
the call.

Closes #10648
2022-03-10 11:05:39 -05:00
Gabriel Corado 4c634a087b feat(app): consider reverse tunnel errors in apps HA mechanism (#10734) 2022-03-04 16:17:51 +00:00
Alan Parra ef62c6a5a3 Log when App Service fails due to empty proxy_service.public_addr (#10056)
Log a warning for admins when App Service fails due to an empty Proxy public_addr.

The warning is useful because the handler error tends to get swallowed by the
Web UI, plus it is a more useful for an admin.
2022-02-02 20:14:52 +00:00
Gabriel Corado 86e92be253 feat: app server requests failover (#9288) 2022-01-13 18:24:33 +00:00
Andrew BurkeandRussell Jones 55a9d25d65 Add meta redirect for some routes (#8293)
Some of the redirects in our oidc/saml workflows create very large headers, which some users' middleware may block. This change performs those redirects with a <meta> redirect instead.

Co-authored-by: Russell Jones <russjones@users.noreply.github.com>
2021-11-11 13:33:50 -08:00
rosstimothy 5cd7c3c294 Split auth.AccessPoint into variant specific interfaces (#8471) 2021-11-04 09:42:14 -04:00
Roman TkachenkoandStefan Sedich 8c3fac832c Set flush interval when forwarding application http requests (#8359)
Signed-off-by: Roman Tkachenko <roman@gravitational.com>

Co-authored-by: Stefan Sedich <stefan.sedich@gmail.com>
2021-09-28 15:16:57 -07:00
Marek Smoliński c142b656c8 ALPN SNI Proxy (#7524) 2021-09-13 11:54:49 +02:00
Roman Tkachenko 4ea2ecdcfc Introduce app server and app resources (#8140) 2021-09-09 14:19:02 -07:00
Brian Joerger 9b8b9d6d0c rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00
Brian Joerger c040aca4c1 Upgrade api version. (#7609) 2021-07-28 13:51:21 -07:00
Roman Tkachenko 1576833094 AWS console access (#7590) 2021-07-26 08:17:16 -07:00
Roman Tkachenko 6c34385e35 Fix ping endpoint when proxy has multiple public addrs (#7368) 2021-06-23 13:00:46 -07:00
Brian Joerger 4d36870ff0 Remove remaining API aliases (#7137) 2021-06-08 12:08:55 -07:00
Brian Joerger 7bff7c41bd Remove API aliases (#6983) 2021-06-04 13:29:31 -07:00
Andrej Tokarčík 8e5ff95014 Provide a dedicated API endpoint for app FQDN resolving (#6449)
Currently, an app's target FQDN can be obtained only using the endpoint
for creating new app sessions.  The OAuth-style back-and-forth redirects
between the app launcher and the app itself are therefore forced to
generate an unnecessary additional app session just to resolve the FQDN.

The new endpoint introduced here allows to resolve such FQDNs by
invoking a dedicated endpoint.
2021-04-26 13:31:56 -07:00
Roman Tkachenko a3837f6720 App access cli flow (#5918) 2021-03-22 09:18:53 -07:00
Roman Tkachenko b2ff4df8fa Fix app access websockets support (#6072) 2021-03-22 08:56:44 -07:00
Andrej Tokarčík ee7693f41d Prevent AAP login CSRF with OAuth-style state tokens 2021-03-01 22:14:10 +01:00
Andrej Tokarčík ff18d38d7e Set cookies with '__Host-' prefix 2021-03-01 22:14:10 +01:00
Andrej Tokarčík c4faea980f Set stricter HTTP Content-Security-Policy directives 2021-03-01 22:14:10 +01:00
Andrej Tokarčík 8720b1872a Assemble safe FQDN values for AAP redirects 2021-03-01 22:14:10 +01:00
Andrej Tokarčík a7f3a05e53 Fix AAP headers injection 2021-03-01 22:14:10 +01:00
Roman Tkachenko 81670e6c2c Relax app session cookie same-site policy (#5565) 2021-02-17 14:07:00 -08:00
Sasha Klizhentas c0bb732545 Adds ACME - auto cert management
This commit fixes #5177

Initial implementation uses dir backend as a cache and is OK
for small clusters, but will be a problem for many proxies.

This implementation uses Go autocert that is quite limited
compared to Caddy's certmagic or lego.

Autocert has no OCSP stapling and no locking for cache for example.
However, it is much simpler and has no dependencies.
It will be easier to extend to use Teleport backend as a cert cache.

```yaml
proxy_service:
  public_addr: ['example.com']
  # ACME - automatic certificate management environment.
  #
  # It provisions certificates for domains and
  # valid subdomains in public_addr section.
  #
  # The sudomains are valid if there is a registered application.
  # For example, app.example.com will get a cert if app is a regsitered
  # application access app. The sudomain cookie.example.com is not.
  #
  # Teleport acme is using TLS-ALPN-01 challenge:
  #
  # https://letsencrypt.org/docs/challenge-types/#tls-alpn-01
  #
  acme:
    # By default acme is disabled.
    enabled: true
    # Use a custom URI, for example staging is
    #
    # https://acme-staging-v02.api.letsencrypt.org/directory
    #
    # Default is letsencrypt.org production URL:
    #
    # https://acme-v02.api.letsencrypt.org/directory
    uri: ''
    # Set email to receive alerts and other correspondence
    # from your certificate authority.
    email: 'alice@example.com'
```
2020-12-22 17:33:20 -08:00
Russell Jones 768b58351f Changed redirect endpoint when session is expired.
When the user does not have a session, if the user tries to access a
proxied application at it's FQDN, Teleport does best effort resolution.

This fix changes the behavior of what happens when the user has a
session but the session is expired. The user was being redirected to the
login page. This fix changes the behavior to by in sync with the
no-session behavior in doing best effort resolution.
2020-11-13 16:15:33 -08:00
Russell Jones f13040a433 Added integration tests for Application Access. 2020-11-12 18:01:45 -08:00
Russell Jones 5a524de54a Fixed regression in application access dialing.
Pass the target address, in the case of application access
services.LocalNode, in the Dial request to the reverse tunnel subsystem
instead of filling it in within the reverse tunnel subsystem.
2020-11-10 16:09:19 -08:00