Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

fowards path parameter to app access authentication #913

Merged
merged 3 commits into from
Jun 29, 2022

Conversation

avatus
Copy link
Contributor

@avatus avatus commented Jun 23, 2022

The Problem:
When a user navigates to an app url with a path included like https://app1.teleport.example.com/my/path without authentication, the path is lost during the authentication process and eventually just gets the root path instead.

This isn't a problem when launching from the Apps dashboard because 1, they are already authenticated, and 2, the launch button sends to the root path anyway. So the problem usually persists when someone is either sharing a link with a path included to a coworker, or when visiting a bookmark or whatever.

The current redirect URI only includes the host name (in this example above, it would be app1.teleport.example.com) because the /web/launch/:fqdn URI expects only the name of the app.

The Solution:
Because we cannot just simply pass the entire path to the redirect_uri, we have to include it as a query parameter. However, there is a bunch of redirects that happen between the Login screen and the final destination so we have to preserve that parameter the whole way through the process. Admittedly, most of this will happen in the api (not yet merged in). The code contained in this PR will help keep the path parameter during the x-teleport-auth api calls. (seen here)

Steps to reproduce:
Add an app to your teleport config if not already included

app_service:
  enabled: 'yes'
  apps:
    - name: 'app1'
      uri: 'http://localhost:8000'
      public_addr: 'app1.your.teleport.url'

Make sure an app is running, for example python3 -m http.server 8000, and be sure to be unauthenticated.

Visit https://app1.your.teleport.url/example/path

In the current codebase, after authenticating, you'll lose the path and end up at https://app1.your.teleport.url.

If you wanna check the teleport core side, make sure to checkout the branch

@avatus avatus requested a review from rudream June 27, 2022 14:22
Copy link
Contributor

@hatched hatched left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good.

Could you add some more comments into this code as to why it's necessary though? Maybe a truncated version of our discussion offline?

packages/teleport/src/AppLauncher/useAppLauncher.ts Outdated Show resolved Hide resolved
@avatus avatus force-pushed the michaelmyers/preserve-app-url branch from 6f00793 to 83d6ac1 Compare June 27, 2022 17:43
@avatus avatus force-pushed the michaelmyers/preserve-app-url branch from 8ae7680 to bf5c954 Compare June 29, 2022 20:19
@avatus avatus merged commit 7037b5b into master Jun 29, 2022
avatus added a commit that referenced this pull request Jul 7, 2022
* fowards path parameter to app access authentication

* add some comments and clearer naming convention

* revert params change, single line comment
avatus added a commit that referenced this pull request Jul 7, 2022
* fowards path parameter to app access authentication

* add some comments and clearer naming convention

* revert params change, single line comment
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants