portalgun_lib

Crates.ioportalgun_lib
lib.rsportalgun_lib
version0.2.2
sourcesrc
created_at2023-05-26 13:06:32.835843
updated_at2023-09-22 10:20:44.284369
descriptionexpose your local web server to the internet with a public url
homepage
repositoryhttps://github.com/perillamint/portalgun
max_upload_size
id874988
size11,037
(perillamint)

documentation

README

portalgun

portalgun lets you expose your locally running web server via a public URL. Written in Rust. Built completely with async-io on top of tokio.

  1. Install
  2. Usage Instructions
  3. Host it yourself

Install

Cargo

cargo install portalgun

Everywhere

Or Download a release for your target OS here: portalgun/releases

Usage

Quick Start

portalgun --port 8000

The above command opens a tunnel and forwards traffic to localhost:8000.

More Options:

Expose your local web server to the internet with a public url.

Usage: portalgun [OPTIONS] [COMMAND]

Commands:
  login  Login using OpenID Connect. This will store the authentication token on disk for future use
  help   Print this message or the help of the given subcommand(s)

Options:
  -v, --verbose
          A level of verbosity, and can be used multiple times
  -s, --sub-domain <SUB_DOMAIN>
          Specify a sub-domain for this tunnel
      --host <LOCAL_HOST>
          Sets the HOST (i.e. localhost) to forward incoming tunnel traffic to [default: localhost]
  -t, --use-tls
          Sets the protocol for local forwarding (i.e. https://localhost) to forward incoming tunnel traffic to
      --port <PORT>
          Sets the port to forward incoming tunnel traffic to on the target host [default: 8000]
      --dashboard-port <DASHBOARD_PORT>
          Sets the address of the local introspection dashboard
  -h, --help
          Print help

Host it yourself

  1. See Dockerfile for a simple alpine based image that runs that server binary.
  2. Deploy the image where ever you want.

OIDC provider setup

Portalgun uses following custom attribute to determine user is allowed to create portal on specific subdomain.

{
  "portalgun": [
    ".*",
    "or-any-subdomain-matching-regexp-in-here
  ]
}

Admins must configure their identity provider appropriately.

Testing Locally

# Run the Server: xpects TCP traffic on 8080 and control websockets on 5000
ALLOWED_HOSTS='localhost' TUNNEL_HOST='localhost' OIDC_DISCOVERY='https://example.com/.well-known/openid-configuration' OIDC_CLIENT_ID='openid-client-id-here' OIDC_SCOPES='openid,portalgun' cargo run --bin portalgun_moon

# Logging in using OIDC
cargo run --bin portalgun login --control-server ws://localhost:5000  

# Test it out!
# Remember 8080 is our local portalgun TCP server
curl -H '<subdomain>.localhost' "http://localhost:8080/some_path?with=somequery"

See portalgun_moon/src/config.rs for the environment variables for configuration.

Commit count: 172

cargo fmt