Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - allow passing environment variables, user-name and password #166

Open
wants to merge 1 commit into
base: release-1.0
Choose a base branch
from

Conversation

asegu
Copy link

@asegu asegu commented Aug 30, 2017

Changes made to satisfy a personal use-case:

Running GoTTY with "-c user:pass login -p %u" (+ config file for TLS), and accessing GoTTY via a url similar to https://example.com/?env=GOTTY=present&env=TMUXname=asession

This, in combination with some edits in .bashrc allows me to login to a TMUX session named on the URL.
Reasoning about login: extra layer of security - don't allow brute force of real password via GoTTY / don't put real password in config, but also skip retyping the user-name.

Note: feature added to 1.0 release as had started looking at code before it was branched off, started looking at how to implement this with the current master branch, but my build environment is not working for this branch at the moment (go objecting to use of "*http.Server ServeTLS(...)" for no good reason I can see)

… password to be passed as arguments to the command being started

Useful in combination with the command 'login -p %u' (asks for password, then starts session).
Useful in combination with bashrc scripts which start a different session (ex: tmux with a given session name) if logging in via GoTTY (based on presence of an environment variable).
@yudai
Copy link
Owner

yudai commented Aug 31, 2017

Thank you for the PR.
Does the --permit-arguments + some scripting satisfy your use case? You can use a URL with parameters like http://localhost:8080/?arg=asession&arg=whatever. And your script can get those parameter and set some context such as env variables, then you can exec login.

Note: feature added to 1.0 release as had started looking at code before it was branched off, started looking at how to implement this with the current master branch, but my build environment is not working for this branch at the moment (go objecting to use of "*http.Server ServeTLS(...)" for no good reason I can see)

You need go1.9, which newly introduced ServeTLS().

@asegu
Copy link
Author

asegu commented Sep 1, 2017

I tried, and yes, I could fulfill my needs by passing arguments to a script which prepares the needed environment variable.

I have to say, I still find the ability to pass in environment variables elegant:

  • there's no secondary script
  • The Variable=Value format allows direct access to variables without extra parsing

It is tending (if also combining the set uid/gid aspect of #167) to bring it such that you can control all elements of the program started by GoTTY.

@yudai
Copy link
Owner

yudai commented Sep 2, 2017

@asegu Thanks for the reply.
I think that letting clients set environment variables directly is unacceptable for security reason. Environment variables are used for many purposes so if a client give an unexpected variable for the user of GoTTY, it can be a volubility. Just like GoTTY accepts a basic auth credentials by an environment variable, other applications can have sensitive environment variables as well (as for login, clients do anything on their session, so the impact is minimum).
At least, we need a white list of variable names that clients can overwrite.

Wondering if named args can be useful, like:

Run gotty with gotty some-command --mode {{mode}} some-sub-command {{target}} , then you can give http://localhost:8080/?mode=m0&target=t0.

When you want to set env variables, you may run gotty like below?

gotty env tmux={{tmux}} login

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants