Skip to content

pass web headers/environment to shell program #62

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

Closed
risacher opened this issue Jan 23, 2013 · 10 comments
Closed

pass web headers/environment to shell program #62

risacher opened this issue Jan 23, 2013 · 10 comments

Comments

@risacher
Copy link

Feature idea: I would like to be able to pass the information about the web environment to the shell program somehow (either as arguments or as environment variables)

e.g. variables such as REMOTE_ADDR, HTTP_X_FORWARDED_FOR could be exposed to the underlying shell program.

Ultimately, I want my reverse proxy server to authenticate the user and pass a SAML assertion (or equivalent) to tty.js, so the shell program can use upstream authentication.

@carsonoid
Copy link

I second this. Something as simple as the ability to pass shell arguments after starting the process would be great. Right now it looks like shellArgs is not editable on the fly.

@chjj
Copy link
Owner

chjj commented Mar 15, 2013

That's funny, I actually just committed a small change which allows shell and shellArgs to be callbacks. Pushing.

@carsonoid
Copy link

That's awesome! How would you recommend we pass data from the web environment to the callbacks? (Textbox values etc.)

@chjj
Copy link
Owner

chjj commented Mar 18, 2013

Example:

    var app = tty.createServer({
      shell: function(session) {
        return session.req.headers['x-process'] || 'bash';
      },
      shellArgs: function(session) {
        return session.req.headers['x-args'].split(' ');
      },
      port: 8000
    });

@chjj
Copy link
Owner

chjj commented Mar 19, 2013

I will probably make an env option which can take a callback as well.

@carsonoid
Copy link

Ok thanks that helped a bunch!

@risacher risacher closed this as completed Dec 7, 2013
@adamjimenez
Copy link

how do you send the x- headers from the client?

@chjj
Copy link
Owner

chjj commented Feb 24, 2014

@adamjimenez, depends on the client. This isn't limited to headers. You could parse a querystring for args if you wanted to.

@adamjimenez
Copy link

I guess the best place would be when I do:

this.socket.emit('create', cols, rows, function(err, data) {

But this only accepts rows and cols and I want to pass different shellargs each time. So that users can open connections to different hosts.

@adamjimenez
Copy link

adamjimenez commented Jan 21, 2022

@adamjimenez, depends on the client. This isn't limited to headers. You could parse a querystring for args if you wanted to.

I could but I want to re-use an existing socket in order to handle simultaneous connections.

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

No branches or pull requests

4 participants