Skip to content

Commit

Permalink
Merge pull request #11 from parabuzzle/add_basic_auth/issue_8
Browse files Browse the repository at this point in the history
add basic auth support
  • Loading branch information
parabuzzle committed May 18, 2016
2 parents 1b0e8b4 + 7920812 commit 688ac19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,25 @@ docker run -d -p 80:80 parabuzzle/craneoperator:latest

## How do I configure it?

Available Environment Variables:

* **REGISTRY_HOST** - the registry host to browse (default: `localhost`)
* **REGISTRY_PORT** - the port of the registry host (default: `5000`)
* **REGISTRY_PROTO** - the protocol to use (ie: `http` or `https`) (default: `https`)
* **REGISTRY_SSL_VERIFY** - should the certificate be verified if using SSL (default: `true`)
* **USERNAME** - setting this will activate BASIC AUTH and require this username
* **PASSWORD** - optional password for BASIC AUTH (you must set the `USERNAME` for this to work)

```
docker run -d \
-p 80:80 \
-e REGISTRY_HOST=registry.yourdomain.com \
-e REGISTRY_PORT=443 \
-e REGISTRY_PROTO=https \
-e REGISTRY_SSL_VERIFY=false \
-e USERNAME=admin \
-e PASSWORD=s3cr3t \
parabuzzle/craneoperator:latest
```

![screenshots/Crane_Operator.jpg](screenshots/Crane_Operator.jpg)
8 changes: 8 additions & 0 deletions server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def registry_ssl_verify
ENV['REGISTRY_SSL_VERIFY'] || 'true'
end

## Authentication ##

if ENV['USERNAME']
use Rack::Auth::Basic, "Please Authenticate to View" do |username, password|
username == ENV['USERNAME'] and password == ( ENV['PASSWORD'] || '' )
end
end

## Helpers ##

def to_bool(str)
Expand Down

0 comments on commit 688ac19

Please sign in to comment.