Skip to content

Commit

Permalink
updated installation/setup instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
handnot2 committed Aug 17, 2017
1 parent 10c3050 commit c071798
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 69 deletions.
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,20 @@ available in as a request header in a proxy forward would work as well.

### Noa Playground

There is a companion Github Repo [Noa Playground](https://github.com/handnot2/noa_playground). This is very
similar to Google OAuth2 Playground. Once Noa is setup and running
There is a companion Github Repo [Noa Playground](https://github.com/handnot2/noa_playground).
This is very similar to Google OAuth2 Playground. Once Noa is setup and running
you can use Noa Playground to try-out Authorization Code Grant flow
end-to-end without writing any code! Make sure to get Noa installed before you follow the instructions on setting up the playground.
end-to-end without writing any code!

Make sure to get Noa installed before you follow the instructions on setting up the playground.

## Installation

Make sure that you have Elixir 1.5.0/Erlang 20.0.x, Nodejs, npm
and Docker installed.

### Build Docker Image

```
git clone https://github.com/handnot2/noa
cd noa
Expand All @@ -90,32 +94,27 @@ sudo mix docker.release --no-cache
> `docker.release` commands, insert `env "PATH=$PATH"` between sudo
> and mix in the above commands.
Continue with installation with the following commands:

```
./noa_docker_setup.sh
```

This will prompt you to make credential file for the end-user
authentication. Just follow the simple instructions you see on the
console. The next part is to prep the database with migration and
seeding. (The database instance is automatically created from the
earlier step.)
### Noa Installation using Docker Image

```
./noa_docker_init.sh ${HOME}/mynoa
cd ${HOME}/mynoa
vim seeds/ro_quickstart.creds
./noa_docker_seed.sh
```

You will have to restart the Noa Docker Containers at the end.
Console output from the above command will tell you exactly what to do.
Checkout the `README.md` file in `${HOME}/mynoa` for instructions on
`seeds/ro_quickstart.creds` file.

At the end of this you will have a docker base instance of Noa running.
At the end of this you will have a docker based instance of Noa running.
From this point out, you simply use `docker-compose` to manage Noa.

> Make sure to add
>
> `127.0.0.1 my.noa`
>
> To your `/etc/hosts` file.
Once this done, you can quickly get `Noa Playground` (OAuth2 Playground)
up and running to try out Noa.
Head over to [Noa Playground](https://github.com/handnot2/noa_playground).
Instructions over there show how to setup your own local OAuth2 Playground
to work with Noa.
53 changes: 53 additions & 0 deletions README.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Noa OAuth2 Server Setup

### Create Resource Owner Credentials file

Edit `seeds/ro_quickstart.creds` file and add the end user
credentials - one line per user. The format is `signin-name:password`.

You might want to keep a copy of this somewhere else in case you end up
recreating this Noa try-out setup.

### Seed Noa Setup

Before you can start using this setup, you need to bootstrap
it with Ecto migration and a set of authorization providers,
OAuth2 clients, definitions of protected resources
(with scope and registered redirect URIs etc). The definitions are
available in `seeds/demo_seed_data.yml` file.

```
./noa_docker_seed.sh
```

This will use docker-compose to bring up a Postgresql database, Noa
and perform the seeding activities. Upon completion this creates
`seed_output.txt` file. Keep this file around. It contains
the authorization provider URLs and for OAuth2 client IDs.

> OOTB the secret for the OAuth2 clients created during
> this seeding process is the same as their name. You can
> explicitly specify it by adding `client_secret: value`.
> When you are initially trying out, simply go with the
> OOTB setup and use the client name as the `client_secret`,
> `rs1client1` for example.

The OAuth2 clients in the `yml` file are already setup with
callback `redirect_uri` for Noa Playground, Google OAuth2
Playground as well as Postman.

> http://localhost:4004
> https://developers.google.com/oauthplayground
> https://www.getpostman.com/oauth2/callback

All setup ready to go.

### Trying out this Noa instance

You can setup your own OAuth2 Playground by following instructions in
[Noa Playground](https://github.com/handnot2/noa_playground).

### Getting rid of Noa setup

First make sure that the docker containers are stopped and removed.
Then use `sudo` to remove the Noa tryout directory.
16 changes: 8 additions & 8 deletions docker-compose.yml → docker-compose.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ services:
- 8.8.8.8
- 8.8.4.4
env_file:
- ${HOME}/.noa/noa.env
- ./noa.env
ports:
- "5432:5432"
volumes:
- ${HOME}/.noa/pgdc/pgdata:/var/lib/postgresql/data
- ./pgdc/pgdata:/var/lib/postgresql/data
noa:
image: noa:release
dns:
- 8.8.8.8
- 8.8.4.4
env_file:
- ${HOME}/.noa/noa.env
- ./noa.env
environment:
- NOA_HOST=my.noa
- NOA_PORT=4000
Expand All @@ -37,8 +37,8 @@ services:
links:
- db
volumes:
- ${HOME}/.noa/ssl:/opt/app/ssl
- ${HOME}/.noa/seeds:/opt/app/seeds
- ./ssl:/opt/app/ssl
- ./seeds:/opt/app/seeds
command: ["foreground"]
nginx:
image: nginx:alpine
Expand All @@ -50,6 +50,6 @@ services:
links:
- noa
volumes:
- ${HOME}/.noa/nxdc/etc/nginx:/etc/nginx:ro
- ${HOME}/.noa/nxdc/var/log/nginx:/var/log/nginx
- ${HOME}/.noa/ssl:/ssl:ro
- ./nxdc/etc/nginx:/etc/nginx:ro
- ./nxdc/var/log/nginx:/var/log/nginx
- ./ssl:/ssl:ro
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Noa.Mixfile do
use Mix.Project

@version "0.7.2-alpha"
@version "0.7.3-alpha"
@description "OAuth2"
@source_url "https://github.com/handnot2/noa"
@playground_url "https://github.com/handnot2/noa_playground"
Expand Down
45 changes: 19 additions & 26 deletions noa_docker_setup.sh → noa_docker_init.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/sh

NOA_HOME=${HOME}/.noa

if [ -d ${NOA_HOME}/pgdc/pgdata ];
if [ "x$1" = "x" -o -e "$1" ];
then
echo "Noa Docker setup already exists at ${NOA_HOME}"
echo "Run noa_docker_cleanup.sh first"
echo "Provide name of a new directory to create"
echo "Usage: noa_docker_init.sh new-directory-to-create"
exit 1
fi

echo "> Creating ${HOME}"
NOA_HOME="$1"

echo "> Creating ${NOA_HOME}"
mkdir -p ${NOA_HOME}
mkdir -p ${NOA_HOME}/seeds

Expand All @@ -23,29 +23,22 @@ echo "> Copying seed data from priv/repo"
cp priv/repo/seed_data.yml ${NOA_HOME}/seeds/demo_seed_data.yml
echo "> Creating an empty resource owner credential file - ro_quickstart.creds"
touch ${NOA_HOME}/seeds/ro_quickstart.creds

echo "> Bringing up Postgresql"
sudo docker-compose up -d db

echo "> Twiddling while postgres starts up"
sleep 6

echo "> Bringup up Noa"
sudo docker-compose up -d noa

echo "> Bit more twiddling"
sleep 3
echo "> Creating docker-compose.yml"
cp docker-compose.tmpl ${NOA_HOME}/docker-compose.yml
echo "> Copying seeding script: noa_docker_seed.sh"
cp noa_docker_seed.sh ${NOA_HOME}/
echo "> Copying README file"
cp README.tmpl ${NOA_HOME}/README.md

echo ""
echo "Next Steps:"
echo "1. Goto ${NOA_HOME}/seeds"
echo "2. Edit ro_quickstart.creds file and add end user credentials one per line."
echo " Format is username:password"
echo "Next Steps: (covered in ${NOA_HOME}/README.md)"
echo "1. cd ${NOA_HOME}"
echo "2. Edit seeds/ro_quickstart.creds file and add end user credentials"
echo " one per line. Format is: username:password"
echo " Make sure each is a minimum of 4 characters."
echo " **Keep a copy** of this ro_quickstart.creds somewhere else"
echo " So you copy that back here next time."
echo "3. Optional. Take a look at ${NOA_HOME}/seeds/demo_seed_data.yml"
echo " so you can copy that back here next time."
echo "3. Optional. Take a look at seeds/demo_seed_data.yml"
echo " Hold off on making any changes to this yet. You can try making"
echo " changes after you have played with the setup."
echo "4. After you completed the above steps, come back to this directory"
echo " and run ./noa_docker_seed.sh"
echo "4. After you completed the above steps, run ./noa_docker_seed.sh"
41 changes: 26 additions & 15 deletions noa_docker_seed.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,49 @@
#!/bin/sh

NOA_HOME=${HOME}/.noa

if [ ! -d ${NOA_HOME}/pgdc/pgdata ];
if [ -f seed_output.txt ];
then
echo "Run noa_docker_setup.sh before using this."
echo "This is supposed to be run once after setup."
echo "noa_docker_seed.sh can be run only once."
echo "If you faced problems earlier and are trying"
echo "run again, it is better to remove this directory"
echo "and start over. Just keep a copy of seeds/ro_quickstart.creds"
echo "somewhere else you can quickly copy it over when you"
echo "start afresh. Just make sure that any partially created"
echo "Docker containers are removed."
exit 1
fi

echo "> Bringing up Postgresql"
sudo docker-compose up -d db

echo "> Twiddling while postgres starts up"
sleep 6

echo "> Bringup up Noa"
sudo docker-compose up -d noa

echo "> Bit more twiddling"
sleep 5

echo "> Performing Ecto migration"
sudo docker-compose exec noa bin/noa migrate

echo "> Seeding data"
sudo docker-compose exec noa bin/noa seed seeds/demo_seed_data.yml > \
${NOA_HOME}/seed_output.txt
seed_output.txt

echo "> Done. Hopefully things worked without any issues!"
echo "> The seed results are made available in"
echo "> ${NOA_HOME}/seed_output.txt file. Keep this file."
echo "> You will need it later."
echo ""
echo "Next Steps:"
echo "1. Run: sudo docker-compose down"
echo "2. Bring it back up again: sudo docker-compose up -d"
echo " Noa should be up and running. Confirm this."
echo "3. Run: sudo docker-compose logs noa"
echo "1. Run: sudo docker-compose logs noa"
echo " You should see that Phoenix is listening on port 4000"
echo "4. Time to fire up Noa Playground to checkout your own OAuth2 server"
echo "2. Keep the generated seed_output.txt file. It has information"
echo " you need to work with Noa."
echo "3. Time to fire up Noa Playground to checkout your own OAuth2 server."
echo " Head over to https://github.com/handnot2/noa_playground"
echo " for further instructions on Noa Playground."
echo ""
echo "At this point you can use the standard docker-compose commands"
echo "to work with this setup."
echo ""
echo "If you want to stop Noa, just run: sudo docker-compose down."
echo "Use ./noa_docker_cleanup.sh to wipe off this Noa setup."
echo "If you want to wipe off this setup use sudo rm -rf shell command."

0 comments on commit c071798

Please sign in to comment.