copy refresh (#2933)

This commit is contained in:
Alex Fornuto 2022-01-24 11:47:50 -06:00 committed by GitHub
parent 5ba95c41a4
commit b35c9d3048
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,7 @@ meta:
- name: keywords - name: keywords
content: >- content: >-
pomerium, identity access proxy, visual studio code, pomerium, identity access proxy, visual studio code,
authentication, authorization authentication, authorization, code server, vscode, coder, codercom
description: >- description: >-
This guide covers how to add authentication and authorization to a hosted, This guide covers how to add authentication and authorization to a hosted,
fully, online instance of visual studio code. fully, online instance of visual studio code.
@ -15,7 +15,7 @@ description: >-
## Background ## Background
This guide covers using Pomerium to secure an instance of [code-server]. Pomerium is an identity-aware access proxy that can add single-sign-on / access control to any service, including visual studio code. This guide covers using Pomerium to secure an instance of [code-server]. Pomerium is an identity-aware access proxy that can add single-sign-on / access control to any service, including Visual Studio Code.
### Visual Studio Code ### Visual Studio Code
@ -33,25 +33,18 @@ One of the interesting attributes of [Visual Studio Code] is that it is built on
## Pre-requisites ## Pre-requisites
This guide assumes you have already completed one of the [install] guides, and have a working instance of Pomerium up and running. For purpose of this guide, I'm going to use docker-compose, though any other deployment method would work equally well. This guide assumes you have already completed one of the [install] guides, and have a working instance of Pomerium up and running. For purpose of this guide, we'll use [Docker Compose](https://docs.docker.com/compose/), though any other deployment method would work equally well.
## Configure ## Configure
### Pomerium Config ### Add A Route
``` Define a route in your Pomerium configuration file:
# config.yaml
# See detailed configuration settings : https://www.pomerium.com/docs/reference/
authenticate_service_url: https://authenticate.corp.domain.example ```yaml
# identity provider settings : https://www.pomerium.com/docs/identity-providers.html
idp_provider: google
idp_client_id: REPLACE_ME
idp_client_secret: REPLACE_ME
routes: routes:
- from: https://code.corp.domain.example - from: https://code.corp.example.com
to: http://codeserver:8080 to: http://codeserver:8080
policy: policy:
- allow: - allow:
@ -61,67 +54,76 @@ routes:
allow_websockets: true allow_websockets: true
``` ```
### Docker-compose In this example route, `code.corp.example.com` is the publicly accessible route for the route, and `codeserver` is the local hostname for the server or container running code-server.
### Docker Compose
In the `services` section of your `docker-compose.yaml` file, add a block for code-server:
```yaml ```yaml
codeserver: services:
image: codercom/code-server:latest codeserver:
restart: always image: codercom/code-server:latest
ports: restart: always
- 8080:8080 ports:
volumes: - 8080:8080
- ./code-server:/home/coder/project volumes:
command: --auth none --disable-telemetry /home/coder/project - ./code-server:/home/coder/project
command: --auth none --disable-telemetry /home/coder/project
``` ```
### That's it ### Apply and Test
Simply navigate to your domain (e.g. `https://code.corp.domain.example`). 1. Bring up your new code-server container. If you're already running your containers with Docker Compose in detached mode, you can apply changes with `docker-compose up -d`.
![visual studio code pomerium hello world](./img/vscode-helloworld.png) 1. After saving your Pomerium configuration file, you may need to restart the docker Pomerium docker container. This is caused by issues with Docker recognizing timestamp updates for files in volume mounts.
### (Example) Develop Pomerium in Pomerium 1. Navigate to your domain (e.g. `https://code.corp.domain.example`).
![visual studio code pomerium hello world](./img/vscode-helloworld.png)
## Develop Pomerium in Pomerium (Example)
As a final touch, now that we've done all this work we might as well use our new development environment to write some real, actual code. And what better project is there than Pomerium? 😉 As a final touch, now that we've done all this work we might as well use our new development environment to write some real, actual code. And what better project is there than Pomerium? 😉
To build Pomerium, we must [install go](https://golang.org/doc/install) which is as simple as running the following commands in the [integrated terminal]. 1. To build Pomerium, we must [install go](https://golang.org/doc/install) which is as simple as running the following commands in the [integrated terminal]:
```bash ```bash
# install dependencies with apt # install dependencies with apt
sudo apt-get update && sudo apt-get install -y wget make zip sudo apt-get update && sudo apt-get install -y wget make zip
# download go # download go
wget https://golang.org/dl/go1.16.4.linux-amd64.tar.gz wget https://golang.org/dl/go1.16.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.16.4.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.16.4.linux-amd64.tar.gz
``` ```
Then add Go to our [PATH]. 1. Add Go to our [PATH]:
```bash ```bash
# add the following to $HOME/.bashrc # add the following to $HOME/.bashrc
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$(go env GOPATH)/bin export PATH=$PATH:$(go env GOPATH)/bin
``` ```
Reload [PATH] by opening the [integrated terminal] and sourcing the updated `.bashrc` file. 1. Reload [PATH] by opening the [integrated terminal] and sourcing the updated `.bashrc` file:
```bash ```bash
source $HOME/.bashrc source $HOME/.bashrc
``` ```
Finally, now that we've got Go all we need to go is grab the latest source and build. 1. Now that we've got Go all we need to go is grab the latest source and build:
```bash ```bash
# get the latest source # get the latest source
git clone https://github.com/pomerium/pomerium.git git clone https://github.com/pomerium/pomerium.git
# build pomerium # build pomerium
cd pomerium cd pomerium
make build make build
# run pomerium! # run pomerium!
./bin/pomerium --version ./bin/pomerium --version
# v0.14.0-28-g38a75913+38a75913 # v0.14.0-28-g38a75913+38a75913
``` ```
Happy remote hacking!!!😁 Happy remote hacking!!!😁