From dbc274bdedb450e43d4f0aae8d2ee65b72b3c449 Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Tue, 10 Nov 2015 08:53:01 -0600 Subject: [PATCH 1/2] bug fixes to build scripts, and vagrant provisioning --- .gitignore | 4 ++++ README.md | 11 ++++++++--- hosts/proxy/base64-secret/Dockerfile | 2 +- hosts/proxy/config-claim_specs-not-table/Dockerfile | 2 +- .../config-unsupported-claim-spec-type/Dockerfile | 2 +- hosts/proxy/default/Dockerfile | 2 +- nginx-jwt.lua | 2 +- provision-vagrant.sh | 10 +++++++++- scripts/build_proxy_base_image.sh | 3 ++- 9 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index de6295f..599e09a 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,7 @@ npm-debug.log *.lua.swp lib/ nginx-jwt.tar.gz + +# Intellij +.idea/ +*.iml diff --git a/README.md b/README.md index a56cd64..1c75fa2 100644 --- a/README.md +++ b/README.md @@ -211,9 +211,9 @@ Besides being able to install Docker and run Docker directly in the host OS, the sudo ./build run ``` -#### Ubuntu on MacOS (via Vagrant) +#### Vagrant -If your host OS is Mac OS but you'd like to test that the build scripts run on Ubuntu, you can use the provided Vagrant scripts to spin up an Ubuntu VM that has all the necessary tools installed. +If you'd like to test that the build scripts run on Ubuntu VM, you can use the provided Vagrant scripts to spin up an Ubuntu VM that has all the necessary tools installed. First, if you haven't already, install **Vagrant** either by [installing the package](http://www.vagrantup.com/downloads.html) or using [Homebrew](http://sourabhbajaj.com/mac-setup/Vagrant/README.html). @@ -229,7 +229,12 @@ And then SSH into it: vagrant ssh ``` -Once in, you'll need to use git to clone this repo and `cd` into the project: +If you're VM provider (ie Virtualbox) has guest additions installed, it will automatically mount the working directory to /vagrant. + +Due to issues with security around synced folders and symlinks, most providers will explicitly prevent this so npm install will fail on tests. To get around this +if this folder was already mounted there should be a copy in ~/nginx-jwt already copied. + +Otherwise you'll need to use git to clone this repo and `cd` into the project: ```bash git clone THIS_REPO_URL diff --git a/hosts/proxy/base64-secret/Dockerfile b/hosts/proxy/base64-secret/Dockerfile index 103fa6f..7644531 100644 --- a/hosts/proxy/base64-secret/Dockerfile +++ b/hosts/proxy/base64-secret/Dockerfile @@ -1,4 +1,4 @@ -FROM proxy-base-image +FROM auth0/proxy-base-image # secret is base-64 encoded and URL-safe ENV JWT_SECRET="VGhpcyBzZWNyZXQgaXMgc3RvcmVkIGJhc2UtNjQgZW5jb2RlZCBvbiB0aGUgcHJveHkgaG9zdA" diff --git a/hosts/proxy/config-claim_specs-not-table/Dockerfile b/hosts/proxy/config-claim_specs-not-table/Dockerfile index ad01672..deb74e0 100644 --- a/hosts/proxy/config-claim_specs-not-table/Dockerfile +++ b/hosts/proxy/config-claim_specs-not-table/Dockerfile @@ -1,4 +1,4 @@ -FROM proxy-base-image +FROM auth0/proxy-base-image ENV JWT_SECRET="JWTs are the best!" diff --git a/hosts/proxy/config-unsupported-claim-spec-type/Dockerfile b/hosts/proxy/config-unsupported-claim-spec-type/Dockerfile index ad01672..deb74e0 100644 --- a/hosts/proxy/config-unsupported-claim-spec-type/Dockerfile +++ b/hosts/proxy/config-unsupported-claim-spec-type/Dockerfile @@ -1,4 +1,4 @@ -FROM proxy-base-image +FROM auth0/proxy-base-image ENV JWT_SECRET="JWTs are the best!" diff --git a/hosts/proxy/default/Dockerfile b/hosts/proxy/default/Dockerfile index ad01672..deb74e0 100644 --- a/hosts/proxy/default/Dockerfile +++ b/hosts/proxy/default/Dockerfile @@ -1,4 +1,4 @@ -FROM proxy-base-image +FROM auth0/proxy-base-image ENV JWT_SECRET="JWTs are the best!" diff --git a/nginx-jwt.lua b/nginx-jwt.lua index 482765a..b02a808 100644 --- a/nginx-jwt.lua +++ b/nginx-jwt.lua @@ -93,7 +93,7 @@ function M.auth(claim_specs) -- make sure claim spec is a supported type -- TODO: test if spec_action == nil then - ngx.log(ngx.STDERR, "Configuration error: claim_specs arg claim '" .. claim .. "' must be a string or a table") + ngx.log(ngx.STDERR, "Configuration error: claim_specs arg claim '" .. claim .. "' must be a string or a function") ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR) end diff --git a/provision-vagrant.sh b/provision-vagrant.sh index c6ff3de..fe14cdd 100644 --- a/provision-vagrant.sh +++ b/provision-vagrant.sh @@ -25,9 +25,17 @@ curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash - apt-get install --yes nodejs # Install Docker -curl -sSL https://get.docker.com/ubuntu | sh +curl -sSL https://get.docker.com/ | sh + +usermod -aG docker vagrant # Vim settings: echo 'syntax on' > /home/vagrant/.vimrc touch /etc/vagrant-provisioned + +# If your VM provider auto-mounted the current directory under /vagrant, simply copy a copy to prevent npm symlink issues +if [ -e "/vagrant/build" ]; +then + cp -R /vagrant nginx-jwt +fi \ No newline at end of file diff --git a/scripts/build_proxy_base_image.sh b/scripts/build_proxy_base_image.sh index 0364e7e..010464d 100755 --- a/scripts/build_proxy_base_image.sh +++ b/scripts/build_proxy_base_image.sh @@ -15,7 +15,8 @@ image_exists=$(docker images | grep "proxy-base-image\s*$dockerfile_sha1") || tr if [ -z "$image_exists" ]; then echo -e "${blue}Building image${no_color}" - docker build -t="proxy-base-image:$dockerfile_sha1" --force-rm $proxy_base_dir + docker build -t="auth0/proxy-base-image:$dockerfile_sha1" --force-rm $proxy_base_dir + docker tag "auth0/proxy-base-image:$dockerfile_sha1" "auth0/proxy-base-image:latest" else echo -e "${blue}Base image already exists${no_color}" fi From b77be6f8b7bef3cb64cba9914f82661761736570 Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Wed, 11 Nov 2015 09:44:25 -0600 Subject: [PATCH 2/2] fix broken test --- test/test_integration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_integration.js b/test/test_integration.js index c30081c..77ca941 100644 --- a/test/test_integration.js +++ b/test/test_integration.js @@ -265,7 +265,7 @@ describe('proxy', function () { if (err) { done(err); } expect(stderr).to.have.string( - "Configuration error: claim_specs arg claim 'aud' must be a string or a table"); + "Configuration error: claim_specs arg claim 'aud' must be a string or a function"); done(); });