Hydra is a runnable server implementation of the OAuth 2.0 authorization framework and the OpenID Connect Core 1.0. Hydra acts as a middle-man infrastructure between your existing application and any OAuth 2.0 / OpenID Connect clients that consume your APIs.
Table of Contents
- What is Hydra?
- Third-party libraries and projects
What is Hydra?
Hydra is a server implementation of the OAuth 2.0 authorization framework and the OpenID Connect Core 1.0. Existing OAuth2 implementations usually ship as libraries or SDKs such as node-oauth2-server or fosite, or as fully featured identity solutions with user management and user interfaces, such as Dex.
Implementing and using OAuth2 without understanding the whole specification is challenging and prone to errors, even when SDKs are being used. The primary goal of Hydra is to make OAuth 2.0 and OpenID Connect 1.0 better accessible.
Hydra implements the flows described in OAuth2 and OpenID Connect 1.0 without forcing you to use a "Hydra User Management" or some template engine or a predefined front-end. Instead it relies on HTTP redirection and cryptographic methods to verify user consent allowing you to use Hydra with any authentication endpoint, be it authboss, auth0.com or your proprietary PHP authentication.
This section is a quickstart guide to working with Hydra. In-depth docs are available as well:
5 minutes tutorial: Run your very own OAuth2 environment
There are various ways of installing hydra on your system.
The client and server binaries are downloadable at releases.
There is currently no installer available. You have to add the hydra binary to the PATH environment variable yourself or put
the binary in a location that is already in your path (
If you do not understand what that all of this means, ask in our chat channel. We are happy to help.
You can use Hydra without a database, but be aware that restarting, scaling or stopping the container will lose all data:
$ docker run -d --name my-hydra -p 4444:4444 oryam/hydra ec91228cb105db315553499c81918258f52cee9636ea2a4821bdb8226872f54b
Using the client command line interface: You can ssh into the hydra container and execute the hydra command from there:
$ docker exec -i -t <hydra-container-id> /bin/bash # e.g. docker exec -i -t ec91228 /bin/bash root@ec91228cb105:/go/src/github.com/ory-am/hydra# hydra Hydra is a twelve factor OAuth2 and OpenID Connect provider [...]
Building from source
If you wish to compile hydra yourself, you need to install and set up Go 1.5+ and add
$PATH. To do so, run the following commands in a shell (bash, sh, cmd.exe, ...):
go get github.com/ory-am/hydra go get github.com/Masterminds/glide cd $GOPATH/src/github.com/ory-am/hydra glide install go install github.com/ory-am/hydra hydra
Why should I use Hydra? It's not that hard to implement two OAuth2 endpoints and there are numerous SDKs out there!
OAuth2 and OAuth2 related specifications are over 200 written pages. Implementing OAuth2 is easy, getting it right is hard. Even if you use a secure SDK (there are numerous SDKs not secure by design in the wild), messing up the implementation is a real threat - no matter how good you or your team is. To err is human.
An in-depth list of security features is listed in the security guide.
Hydra has received a lot of positive feedback. Let's see what the community is saying:
Nice! Lowering barriers to the use of technologies like these is important.
OAuth is a framework not a protocol. The security it provides can vary greatly between implementations. Fosite (which is what this is based on) is a very good implementation from a security perspective: https://github.com/ory-am/fosite#a-word-on-security
[...] Thanks for releasing this by the way, looks really well engineered. [...]
The Guide is available on GitBook.
HTTP API Documentation
The HTTP API is documented at Apiary.
Command Line Documentation
hydra -h or
Developing with Hydra is as easy as:
go get github.com/ory-am/hydra go get github.com/Masterminds/glide cd $GOPATH/src/github.com/ory-am/hydra glide install go test $(glide novendor)
If you want to run a Hydra instance, there are two possibilities:
Run without Database:
go run main.go host
Run against RethinkDB using Docker:
docker run --name some-rethink -d -p 8080:8080 -p 28015:28015 rethinkdb DATABASE_URL=rethinkdb://localhost:28015/hydra go run main.go host