hydra

command module
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

README

Ory/Hydra

Join mailinglist Join newsletter Follow newsletter Follow GitHub

Build Status Coverage Status Code Climate Go Report Card

Docs Guide HTTP API Documentation Code Documentation

Hydra is being developed by german-based company Ory. Join our newsletter to stay on top of new developments. We offer basic support requests on Google Groups and Gitter as well as consulting around integrating Hydra into your particular environment and premium support.

Hydra uses the security first OAuth2 and OpenID Connect SDK Fosite and Ladon for policy-based access control.

Table of Contents

What is Hydra?

At first, there was the monolith. The monolith worked well with the bespoke authentication module. Then, the web evolved into an elastic cloud that serves thousands of different user agents in every part of the world.

Hydra is driven by the need for a scalable, low-latency, in memory Access Control, OAuth2, and OpenID Connect layer that integrates with every identity provider you can imagine.

  • Hydra is built security first: architecture and work flows are designed to neutralize various common (OWASP TOP TEN) and uncommon attack vectors. Learn more.
  • Hydra can manage all of your access control needs, such as policy based access control and access token validation. Learn more.
  • Hydra depends on an identity provider of your choosing, e.g. authboss, and works with any identity provider that is able to read and issue JSON Web Tokens. Learn more.
  • Hydra has nano-second latency on high profile endpoints, overwhelmingly efficient memory and CPU consumption and scales effortlessly. Learn more.
  • Hydra focuses on ease of use, integration, management and operation. Get Hydra up and running in 5 Minutes.
  • Hydra helps you manage Social Login Connections as well as JSON Web Keys and is planned to help you manage User Groups and Two Factor Authentication as well.
  • Hydra is available through Docker and relies on RethinkDB for persistence. Database drivers are extensible in case you want to use RabbitMQ, MySQL, MongoDB, or some other database instead.

Hydra is built for high volume environments and is capable of serving tens of thousands of simultaneous requests per second per instance. Read this issue for information on reproducing these benchmarks yourself.

What is Hydra / OAuth2 not?

I am new to all of this. When should I reconsider if using OAuth2 / Hydra is the right choice for me?

  1. Hydra is not something that manages user accounts. Hydra does not offer user registration, password reset, user login, sending confirmation emails. This is what the Identity Provider ("login endpoint") is responsible for. The communication between Hydra and the Identity Provider is called Consent Flow. Auth0.com is an Identity Provider. We might implement this feature at some point and if, it is going to be a different product.
  2. If you think running an OAuth2 Provider can solve your user authentication ("log a user in"), Hydra is probably not for you. OAuth2 is a delegation protocol:

The OAuth 2.0 authorization framework enables a third-party application [think: a dropbox app that manages your dropbox photos] to obtain limited access to an HTTP service, either on behalf of [do you allow "amazing photo app" to access all your photos?] a resource owner [user] by orchestrating an approval interaction [consent flow] between the resource owner and the HTTP service, or by allowing the third-party application [OAuth2 Client App] to obtain access on its own behalf.

  1. If you are building a simple service for 50-100 registered users, OAuth2 and Hydra will be overkill.
  2. Hydra does not support the OAuth2 resource owner password credentials flow.
  3. Hydra has no user interface. You must manage OAuth2 Clients and other things using the RESTful endpoints. A user interface is scheduled to accompany the stable release.
When does Hydra / OAuth2 make sense?
  1. If you want third-party developers to access your APIs, Hydra is the perfect fit. This is what an OAuth2 Provider does.
  2. If you want to become a Identity Provider, like Google, Facebook or Microsoft, OpenID Connect and thus Hydra is a perfect fit.
  3. Running an OAuth2 Provider works great with browser, mobile and wearable apps, as you can avoid storing user credentials on the device, phone or wearable and revoke access tokens, and thus access privileges, at any time. Adding OAuth2 complexity to your environment when you never plan to do (1), might not be worth it. Our advice: write a pros/cons list.
  4. If you have a lot of services and want to limit automated access (think: cronjobs) for those services, OAuth2 might make sense for you. Example: The comment service is not allowed to read user passwords when fetching the latest user profile updates.

Feature Overview

  1. Availability: Hydra uses pub/sub to have the latest data available in memory. The in-memory architecture allows for heavy duty workloads.
  2. Scalability: Hydra scales effortlessly on every platform you can imagine, including Heroku, Cloud Foundry, Docker, Google Container Engine and many more.
  3. Integration: Hydra wraps your existing stack like a blanket and keeps it safe. Hydra uses cryptographic tokens to authenticate users and request their consent, no APIs required. The deprecated php-3.0 authentication service your intern wrote? It works with that too, don't worry. We wrote an example with React to show you what this could look like: React.js Identity Provider Example App.
  4. Security: Hydra leverages the security first OAuth2 framework Fosite, encrypts important data at rest, and supports HTTP over TLS (https) out of the box.
  5. Ease of use: Developers and operators are human. Therefore, Hydra is easy to install and manage. Hydra does not care if you use React, Angular, or Cocoa for your user interface. To support you even further, there are APIs available for cryptographic key management, social log on, policy based access control, policy management, and two factor authentication (tbd). Hydra is packaged using Docker.
  6. Open Source: Hydra is licensed under Apache Version 2.0
  7. Professional: Hydra implements peer reviewed open standards published by The Internet Engineering Task Force (IETF®) and the OpenID Foundation and under supervision of the LMU Teaching and Research Unit Programming and Modelling Languages. No funny business.
  8. Real Time: Operation is a lot easier with real time. There are no caches, no invalidation strategies and no magic - just simple, cloud native pub-sub. Hydra leverages RethinkDB, so check out their real time database monitoring too!

Quickstart

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.
Installation

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 -p 4444:4444 oryam/hydra --name my-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 $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
hydra
5 minutes tutorial: Run your very own OAuth2 environment

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

OAuth2 Flow

Security

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.

Reception

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.

Pyxl101

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

abritishguy

[...] Thanks for releasing this by the way, looks really well engineered. [...]

olalonde

Documentation

Guide

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.

Develop

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

Third-party libraries and projects

Hall of Fame

A list of extraordinary contributors and bug hunters.

Documentation

Overview

Package hydra is an api-only cloud native OAuth2 and OpenID Connect provider that integrates with existing authentication mechanisms:

At first, there was the monolith. The monolith worked well with the bespoke authentication module. Then, the web evolved into an elastic cloud that serves thousands of different user agents in every part of the world. Hydra is driven by the need for a scalable, low-latency, in memory Access Control, OAuth2, and OpenID Connect layer that integrates with every identity provider you can imagine. Hydra is available through Docker and relies on RethinkDB for persistence. Database drivers are extensible in case you want to use RabbitMQ, MySQL, MongoDB, or some other database instead. Hydra is built for high throughput environments. Check out the below siege benchmark on a Macbook Pro Late 2013, connected to RethinkDB validating access tokens.

The official repository is located at https://github.com/ory-am/hydra

Directories

Path Synopsis
cmd
cli
Package firewall defines an API for validating access requests.
Package firewall defines an API for validating access requests.
pkg
Package policy offers management capabilities for access control policies.
Package policy offers management capabilities for access control policies.
Package SDK offers convenience functions for Go code around Hydra's HTTP APIs.
Package SDK offers convenience functions for Go code around Hydra's HTTP APIs.
Package warden decides if access requests should be allowed or denied.
Package warden decides if access requests should be allowed or denied.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL