A security-first open source OAuth2 and OpenID Connect server for existing and new (enterprise) infrastructures. Written in Go.
Latest commit b8c10c3 Mar 15, 2017 @arekkas arekkas committed with arekkas docker: reduce docker image size
Failed to load latest commit information.
.docker-home πŸ”₯ 0.1-beta πŸ”₯ May 29, 2016
client sql: improve sql migration routine and add test Jan 2, 2017
cmd cli: resolve typo in host command (#391) Mar 11, 2017
compose compose: resolve issue with firewall set up Dec 30, 2016
config config: remove unused import Feb 11, 2017
docs docs: add example policy for consent app signing (#389) Mar 15, 2017
firewall docs: clean up TokenValid leftovers - closes #310 Nov 22, 2016
herodot herodot: improve error handling Dec 30, 2016
integration sql: improve sql migration routine and add test Jan 2, 2017
jwk all: correct error wrapping Dec 30, 2016
oauth2 oauth2: invalid consent response causes panic - closes #369 Feb 11, 2017
pkg all: correct error wrapping Dec 30, 2016
policy sql: improve sql migration routine and add test Jan 2, 2017
sdk oauth2/consent: force jti echo in consent response -closes #322 Dec 30, 2016
warden sql: improve sql migration routine and add test Jan 2, 2017
.cobra.yaml πŸ”₯ 0.1-beta πŸ”₯ May 29, 2016
.codeclimate.yml πŸ”₯ 0.1-beta2 (#90) πŸ”₯ Jun 14, 2016
.dockerignore docs: update five minute tutorial Dec 30, 2016
.gitignore 0.6.0 (#293) Oct 25, 2016
.travis.yml all: resolve ci issues and improve readme Feb 24, 2017
CONTRIBUTING.md 0.6.0 (#293) Oct 25, 2016
Dockerfile docker: reduce docker image size Mar 16, 2017
Dockerfile-demo docker: reduce docker image size Mar 16, 2017
Dockerfile-http docker: reduce docker image size Mar 16, 2017
LICENSE Update LICENSE Oct 26, 2015
MAINTAINERS doc: create MAINTAINERS Dec 30, 2015
PATRONS.md patron: added wayne robinson Oct 26, 2016
Procfile πŸ”₯ 0.1-beta πŸ”₯ May 29, 2016
README.md docs: add articles section Mar 7, 2017
api-spec.yaml api: remove api spec Dec 30, 2016
api-spec.yaml.bak api: remove api spec Dec 30, 2016
book.json 0.4.0 (#203) Aug 17, 2016
doc.go docs: more docs Oct 25, 2016
docker-compose.yml docker: new constent app image Feb 25, 2017
glide.lock docker: reduce docker image size Mar 16, 2017
glide.yaml docker: reduce docker image size Mar 16, 2017
main.go log: resolve issues with LOG_LEVEL and log confidentiality Dec 12, 2016



Join the chat at https://gitter.im/ory-am/hydra Join mailinglist Join newsletter Follow twitter Follow GitHub Become a patron!

Build Status Coverage Status Code Climate Go Report Card CII Best Practices

Docs Guide HTTP API Documentation Code Documentation

Hydra offers OAuth 2.0 and OpenID Connect Core 1.0 capabilities as a service. Hydra is different, because it works with any existing authentication infrastructure, not just LDAP or SAML. By implementing a consent app (works with any programming language) you build a bridge between Hydra and your authentication infrastructure.

Hydra is able to securely manage JSON Web Keys, and has a sophisticated policy-based access control you can use if you want to.

Hydra is suitable for green- (new) and brownfield (existing) projects. If you are not familiar with OAuth 2.0 and are working on a greenfield project, we recommend evaluating if OAuth 2.0 really serves your purpose. Knowledge of OAuth 2.0 is imperative in understanding what Hydra does and how it works.

Join our newsletter to stay on top of new developments. We answer basic support requests on Google Groups and Gitter and offer premium services around Hydra.

Hydra uses the security first OAuth2 and OpenID Connect SDK Fosite and the access control SDK Ladon.

Table of Contents

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:

  • The documentation is available on GitBook.
  • The REST API documentation is available at Apiary.

5 minutes tutorial: Run your very own OAuth2 environment

The tutorial teaches you to set up Hydra, a Postgres instance and an exemplary identity provider written in React using docker compose. It will take you about 5 minutes to complete the tutorial.

OAuth2 Flow


There are various ways of installing hydra on your system.

Download binaries

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 (/usr/bin, ...). If you do not understand what that all of this means, ask in our chat channel. We are happy to help.

Using Docker

Starting the host is easiest with docker. The host process handles HTTP requests and is backed by a database. Read how to install docker on Linux, OSX or Windows. Hydra is available on Docker Hub.

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 oryd/hydra

Note: We had to create a new docker hub repository. Tags prior to 0.7.5 are available here.

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 $GOPATH/bin to your $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

Note: We changed organization name from ory-am to ory. In order to keep backwards compatibility, we did not rename Go packages.


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/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

Run hydra -h or hydra help.


Developing with Hydra is as easy as:

go get github.com/ory/hydra
go get github.com/Masterminds/glide
cd $GOPATH/src/github.com/ory/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

Libraries and third-party projects



Blog posts & articles