Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.10.0 #557

Merged
merged 88 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
5f41f4a
vendor: update to fosite 0.11.0
Jul 9, 2017
6b71718
vendor: update fosite dependency
Jul 9, 2017
05e130b
all: replace pkg.AssertError with testify error checks
Jul 9, 2017
d2d6000
oauth2: replace HierarchicScopeStrategy with WildcardScopeStrategy
Jul 9, 2017
883d05d
docs: scopes are now wildcard matches
Sep 15, 2017
cc16467
docs: add wildcard scope strategy documentation
Sep 16, 2017
745089c
all: ran gofmt and goimports
Sep 16, 2017
38d41d3
all: add short mode for tests
Sep 16, 2017
4ca3e08
travis: make scripts executable
Sep 16, 2017
97908dd
travis: add gofmt testing
Sep 16, 2017
962d22b
travis: improve scripts
Sep 16, 2017
f58d7fd
metrics: resolve race issue
Sep 17, 2017
c9a517b
scripts: update format script
Sep 17, 2017
f4f5904
oauth2: replace jwk-based with http-based consent flow
Sep 17, 2017
7db8383
all: update scripts and format code
Sep 18, 2017
2a68068
cmd: adapt to new consent manager
Sep 18, 2017
29724c3
sdk: remove outdated consent helper
Sep 18, 2017
b0a267f
all: write swagger docs
Sep 26, 2017
d0a3c9b
all: finalize tests and format
Sep 26, 2017
634f558
sdk: add node and go SDK from swagger codegen
Sep 26, 2017
36ec5a2
sdk/go: move go sdk to appropriate package
Sep 26, 2017
66caaa7
client: write test for swagger codegen sdk
Sep 26, 2017
b136cd2
client: force swagger array type in list response
Sep 26, 2017
1a393ae
client: appropriately handle client secret responses
Sep 26, 2017
e26f53d
client: add memory manager instantiator
Sep 26, 2017
d5827aa
sdk: update swagger definitions and codegens
Sep 26, 2017
1c6ae45
client: return array instead of object on list endpoint
Sep 26, 2017
868b042
client: finalize SDK tests
Sep 26, 2017
81d165b
all: run gofmt
Sep 26, 2017
e2556c1
client: remove obsolete http manager
Sep 26, 2017
81badaa
sdk/go: switch to resty master for oauth2 compatibility
Sep 27, 2017
a70a9a1
client: clean up sdk tests
Sep 27, 2017
2e92683
cmd/client: use new sdk for client cli
Sep 27, 2017
65bf3e9
scripts: add swagger codegen cli to repo
Sep 27, 2017
8480c23
sdk: update swagger definitions
Sep 27, 2017
9fa24a5
all: run gofmt
Sep 27, 2017
a17cc2d
all: update swagger definitions
Sep 27, 2017
399030f
jwk: implement swagger-based sdk
Sep 27, 2017
ae886ba
scripts: remove swagger-codegen jar from git
Sep 27, 2017
76ad66a
oauth2: improve swagger definitions
Sep 27, 2017
7eeb995
oauth2: improve swagger spec and generate/test client for revoke
Sep 27, 2017
3b6c01c
client: resolve failing test
Sep 27, 2017
bf0b5ca
scripts: update sdk generator script
Sep 27, 2017
2805d52
sdk: move sdk one directory down
Sep 27, 2017
303c85d
all: add hydra to swagger tags
Sep 27, 2017
f379e3a
oauth2: implement swagger-based sdk
Sep 27, 2017
82bb7ac
sdk: allow redirects in resty client
Sep 27, 2017
ef01c36
all: update swagger definitions and combine in hydra interface
Sep 27, 2017
5be2489
policy: implement policy sdk and tests based on swagger
Sep 27, 2017
45096c4
cmd/cli: fake-tls-termination and refactoring errors checks
Sep 27, 2017
f35209c
cmd/cli: implement policy handler based on swagger client
Sep 27, 2017
45b67c6
all: reduce tags to one and clean up sdk
Sep 27, 2017
385f933
vendor: add go-resty to glide dependencies
Sep 28, 2017
000b8d3
travis: update swagger location
Sep 28, 2017
16d231c
all: improve swagger documentation of all modules
Sep 28, 2017
4bfc81a
warden: implement swagger based SDK and write tests
Sep 28, 2017
42cdbd0
oauth2: return consent deny reason to oauth2 initiator
Sep 28, 2017
afa6d6d
docs: add API version note
Sep 28, 2017
8d59b1f
warden/group: refactor group sdk and group management interface
Sep 29, 2017
147ecdc
sdk: update sdk definitions
Sep 29, 2017
b4226eb
all: update swagger definitions and fix failing tests
Sep 29, 2017
49b7d07
warden: remove payload from warden token response name
Oct 4, 2017
bce6245
sdk/go: write interfaces for APIs & responses
Oct 4, 2017
ce70f88
docs: write down changes to history.md
Oct 4, 2017
0346c5c
docs: document go sdk
Oct 4, 2017
451f665
docs: remove old resources
Oct 4, 2017
393805b
docs: improve 0.10.0 history
Oct 4, 2017
86a5518
docs: remove consent jwk hints
Oct 4, 2017
c79425e
docs: fix exists -> exits typo
Oct 4, 2017
c05092f
docs: clean up stale contribute.md
Oct 4, 2017
5a13346
docs: clarify tls termination functionality
Oct 4, 2017
7741338
docs: document go and js sdk
Oct 5, 2017
5507272
sdk/js: officially publish nodejs sdk
Oct 5, 2017
6264348
sdk: revert audience changes
Oct 5, 2017
c8eed9c
docs/sdk: link sdk docs to readme files
Oct 5, 2017
89be3da
docs: write docs on new consent flow
Oct 5, 2017
cba000e
docs: link history.md to new consent flow section
Oct 5, 2017
2b3f971
scripts: force linefeed on windows
Oct 5, 2017
8b071e3
scripts: scripts now format sdk files as well
Oct 5, 2017
8e2a36a
sdk/go: add helpers for oauth2 configuration
Oct 5, 2017
1ae021e
oauth2: rename audience to client_id/clientId
Oct 5, 2017
3c00413
warden: replace response shorthands with more readable names
Oct 5, 2017
2ce917b
sdk/js: set version to latest to prevent accidental publish
Oct 5, 2017
2e8c5c2
vendor: update glide.lock
Oct 5, 2017
1492afe
scripts: force linefeed
Oct 5, 2017
47cb69b
docs: notify upgrades of scope change
Oct 5, 2017
dae8df7
oauth2: write test for handling consent deny
Oct 5, 2017
75ce955
docker: update to go 1.9 and update compose.yml
Oct 5, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ output/
_book/
dist/
coverage.*
docs/api.swagger.json
Dockerfile-plugin-*
plugin-*.so
21 changes: 21 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
client/
cmd/
compose/
config/
docs/
firewall/
health/
integration/
jwk/
metrics/
oauth2/
pkg/
policy/
rand/
scripts/
sdk/go/
vendor/
warden/
*.yml
*.go
*.md
51 changes: 25 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,45 @@ before_install:
- sudo apt-get install curl

install:
- go get github.com/mattn/goveralls golang.org/x/tools/cmd/cover github.com/Masterminds/glide github.com/mitchellh/gox
- go get -u github.com/go-swagger/go-swagger/cmd/swagger github.com/bradfitz/goimports github.com/mattn/goveralls golang.org/x/tools/cmd/cover github.com/Masterminds/glide github.com/mitchellh/gox github.com/ory/go-acc
- git clone https://github.com/docker-library/official-images.git ~/official-images
- glide install
- go install github.com/ory/hydra
- glide update
- go install github.com/ory/hydra

script:
- touch ./coverage.tmp
- |
echo 'mode: atomic' > coverage.txt
- |
go list ./... | grep -v /cmd | grep -v /vendor | xargs -n1 -I{} sh -c 'go test -race -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | grep -v /vendor | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.txt || exit 255' && rm coverage.tmp
- touch ./coverage.tmp
- |
go list ./cmd/... | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | grep -v /vendor | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.txt || exit 255' && rm coverage.tmp
- goveralls -coverprofile="coverage.txt"
- ./scripts/test-format.sh
- go-acc -o coverage.txt $(glide novendor)
- go test -race -short $(glide novendor | grep -v cmd)
- docker build -t hydra-travis-ci -f Dockerfile-without-telemetry .
- docker run -d hydra-travis-ci
- DATABASE_URL=memory hydra host --dangerous-auto-logon --dangerous-force-http --disable-telemetry &
- while ! echo exit | nc localhost 4444; do sleep 1; done
# Test clients
- hydra clients create --id foobar
- hydra clients delete foobar
# Test token on arbitrary endpoints
- |-
curl --header "Authorization: bearer $(hydra token client)" http://localhost:4444/clients
# Test token validation
- hydra token validate $(hydra token client)
- ./scripts/test-e2e.sh
- ./scripts/run-genswag.sh

after_success:
- |-
[ "${TRAVIS_TAG}" != "" ] && gox -ldflags "-X github.com/ory/hydra/cmd.Version=`git describe --tags` -X github.com/ory/hydra/cmd.BuildTime=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` -X github.com/ory/hydra/cmd.GitHash=`git rev-parse HEAD`" -output "dist/{{.Dir}}-{{.OS}}-{{.Arch}}"



before_deploy:
- npm version --no-git-tag-version $(git describe --tag)

deploy:
provider: releases
file_glob: true
api_key: "$GITHUB_TOKEN"
file: "dist/*"
skip_cleanup: true
on:
tags: true
go: 1.8
- provider: npm
api_key: "$NPM_TOKEN"
email: "$NPM_EMAIL"
skip_cleanup: true
on:
tags: true
- provider: releases
file_glob: true
api_key: "$GITHUB_TOKEN"
file: "dist/*"
skip_cleanup: true
on:
tags: true
go: 1.9
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.8-alpine
FROM golang:1.9-alpine

RUN apk add --no-cache git build-base
RUN go get github.com/Masterminds/glide
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-automigrate
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.8-alpine
FROM golang:1.9-alpine

RUN apk add --no-cache git build-base
RUN go get github.com/Masterminds/glide
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-demo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.8-alpine
FROM golang:1.9-alpine

RUN apk add --no-cache git build-base
RUN go get github.com/Masterminds/glide
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-http
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.8-alpine
FROM golang:1.9-alpine

RUN apk add --no-cache git build-base
RUN go get github.com/Masterminds/glide
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-without-telemetry
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.8-alpine
FROM golang:1.9-alpine

RUN apk add --no-cache git build-base
RUN go get github.com/Masterminds/glide
Expand Down
100 changes: 100 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,106 @@

This list makes you aware of (breaking) changes. For patch notes, please check the [releases tab](https://github.com/ory/hydra/releases).

## 0.10.0-alpha1

**Warning: This version introduces breaking changes and is not suited for production use yet.**

Version 0.10.0 is a preview tag of the 1.0.0 release. It contains multiple breaking changes.

This release requires running `hydra migrate sql` before `hydra host`.

Please also note that the new scope strategy might render your administrative client incapable of performing requests.
Set the environment variable `SCOPE_STRATEGY=DEPRECATED_HIERARCHICAL_SCOPE_STRATEGY` to temporarily use the previous
scope strategy and migrate the scopes manually. You may append `.*` to all scopes. For example, `hydra` is now `hydra hydra.*`

## New consent flow

Previously, the consent flow looked roughly like this:

1. App asks user for Authorization by generating the authorization URL (http://hydra.mydomain.com/oauth2/auth?client_id=...).
1. Hydra asks browser of user for authentication by redirecting to the Consent App with a *consent challenge* (http://login.mydomain.com/login?challenge=xYt...).
1. Retrieves a RSA 256 public key from Hydra.
2. Uses said public key to verify the consent challenge.
3. User logs in and authorizes the requested scopes
4. Consent app generates the consent response
1. Retrieves a private key from Hydra which is used to sign the consent response.
2. Creates a response message and sign with said private key.
3. Redirects the browser back to Hydra, appending the consent response (http://hydra.mydomain.com/oauth2/auth?client_id=...&consent=zxI...).
6. Hydra validates consent response and generates access tokens, authorize codes, refresh tokens, and id tokens.

This approach has several disadvantages:

1. Validating and generating the JSON Web Tokens (JWTs) requires libraries for each language
1. Because libraries are required, auto generating SDKs from the swagger spec is impossible. Thus, every language
requires a maintained SDK which significantly increases our workload.
2. There have been at least two major bugs affecting almost all JWT libraries for any language. The spec has been criticised
for it's mushy language.
3. The private key used by the consent app for signing consent responses was originally thought to be stored at the consent
app, not in Hydra. However, since Hydra offers JWK storage, it was decided to use the Hydra JWK store per default for
retrieval of the private key to improve developer experience. However, to make really sense, the private key should have
been stored at the consent app, not in Hydra.
2. Private/Public keypairs need to be fetched on every request or cached in a way that allows for key rotation, complicating
the consent app.
3. There is currently no good mechanism for rotating JWKs in Hydra's storage.
4. The consent challenge / response has a limited length as it's transmitted via the URL query. The length of a URL
is limited.

Due to these reasons we decided to refactor the consent flow. Instead of relying on JWTs using RSA256, a simple HTTP call
is now enough to confirm a consent request:

1. App asks user for Authorization by generating the authorization URL (http://hydra.mydomain.com/oauth2/auth?client_id=...).
1. Hydra asks browser of user for authentication by redirecting to the Consent App with a unique *consent request id* (http://login.mydomain.com/login?consent=fjad2312).
1. Consent app makes a HTTP REST request to `http://hydra.mydomain.com/oauth2/consent/requests/fjad2312` and retrieves information on the authorization request.
3. User logs in and authorizes the requested scopes
4. Consent app accepts or denies the consent request by making a HTTP REST request to `http://hydra.mydomain.com/oauth2/consent/requests/fjad2312/accept` or `http://hydra.mydomain.com/oauth2/consent/requests/fjad2312/reject`.
5. Redirects the browser back to Hydra.
6. Hydra validates consent request by checking if it was accepted and generates access tokens, authorize codes, refresh tokens, and id tokens.

Learn more on how the new consent flow works in the guide: https://ory.gitbooks.io/hydra/content/oauth2.html#consent-flow

## Audience

Previously, the audience terminology was used as a synonym for OAuth2 client IDs. This is no longer the case. The audience
is typically a URL identifying the endpoint(s) the token is intended for. For example, if a client requires access to
endpoint `http://mydomain.com/users`, then the audience would be `http://mydomain.com/users`.

The audience feature is currently not supported in Hydra, only the terminology changed. Fields named `audience` are thus
renamed to `clientId` (where previously named `audience`) and `cid` (where previously named `aud`).

**IMPORTANT NOTE:** This does **not** apply to OpenID Connect ID tokens. There, the `aud` claim **MUST** match the `client_id`.
This discrepancy between OpenID Connect and OAuth 2.0 is what caused the confusion with the OAuth 2.0 audience terminology.

## Response payload changes to `/warden/token/allowed`

Previously, the response of the warden endpoint contained shorthands like `aud`, `iss`, and so on. Those have now been changed
to their full names. For example, `iss` is now `issuer`. Additionally, `aud` is now named `clientId`.

## Go SDK

The Go SDK was completely replaced in favor of a SDK based on `swagger-codegen`. Read more on it here: https://ory.gitbooks.io/hydra/content/sdk/go.html

## Health endpoints

* `GET /health` is now `GET /health/status`
* `GET /health/stats` is now `GET /health/metrics`

## Group endpoints

* `GET /warden/groups` now returns a list of groups, not just a group id

## Refreshing OpenID Connect ID Token using `refresh_token` grant type

1. It is now possible to refresh openid connect tokens using the refresh_token grant. An ID Token is issued if the scope
`openid` was requested, and the client is allowed to receive an ID Token.

## Replacing hierarchical scope strategy with wildcard scope strategy

The previous scope matching strategy has been replaced in favor of a wildcard-based matching strategy. Read more
on this strategy [here](https://ory.gitbooks.io/hydra/content/oauth2.html#oauth2-scopes).

To fall back to hierarchical scope matching, set the environment variable `SCOPE_STRATEGY=DEPRECATED_HIERARCHICAL_SCOPE_STRATEGY`.
This feature *might* be fully removed in the final 1.0.0 version.

## 0.9.0

This version adds performance metrics to `/health` and sends anonymous usage statistics to our servers, [click here](https://ory.gitbooks.io/hydra/content/telemetry.html) for more
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and low resource consumption. ORY Hydra *is not* an identity provider (user sign
but connects to your existing identity provider through a [consent app](https://ory.gitbooks.io/hydra/content/oauth2.html#consent-app-flow).
Implementing the consent app in a different language is easy, and exemplary consent apps
([Go](https://github.com/ory/hydra-consent-app-go), [Node](https://github.com/ory/hydra-consent-app-express)) and
SDKs ([Go](https://github.com/ory/hydra/tree/update-docs/sdk), [Node](https://github.com/ory/hydra-js)) are provided.
[SDKs](https://ory.gitbooks.io/hydra/content/sdk.html) are provided.

Besides mitigating various attack vectors, such as database compromisation and OAuth 2.0 weaknesses, ORY Hydra is
able to securely manage JSON Web Keys, and has a sophisticated policy-based access control you can use if you want to.
Expand Down Expand Up @@ -288,7 +288,6 @@ Fosite (which is what this is based on) is a very good implementation from a sec
## Libraries and third-party projects

Official:
* [Consent App SDK For NodeJS](https://github.com/ory/hydra-js)
* [Consent App Example written in Go](https://github.com/ory/hydra-consent-app-go)
* [Exemplary Consent App with Express and NodeJS](https://github.com/ory/hydra-consent-app-express)

Expand Down
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// Client represents an OAuth 2.0 Client.
//
// swagger:model oauthClient
// swagger:model oAuth2Client
type Client struct {
// ID is the id for this client.
ID string `json:"id" gorethink:"id"`
Expand Down Expand Up @@ -40,7 +40,7 @@ type Client struct {
// described in Section 3.3 of OAuth 2.0 [RFC6749]) that the client
// can use when requesting access tokens.
//
// Pattern: ([a-zA-Z0-9\.]+\s)+
// Pattern: ([a-zA-Z0-9\.\*]+\s)+
Scope string `json:"scope" gorethink:"scope"`

// Owner is a string identifying the owner of the OAuth 2.0 Client.
Expand Down Expand Up @@ -87,7 +87,7 @@ func (c *Client) GetHashedSecret() []byte {
}

func (c *Client) GetScopes() fosite.Arguments {
return fosite.Arguments(strings.Split(c.Scope, " "))
return fosite.Arguments(strings.Fields(c.Scope))
}

func (c *Client) GetGrantTypes() fosite.Arguments {
Expand Down
18 changes: 13 additions & 5 deletions client/doc.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
// Package client implements the OAuth 2.0 Client functionality and provides http handlers, http clients and storage adapters.
// Package client implements OAuth 2.0 client management capabilities
//
// OAuth 2.0 clients are used to perform OAuth 2.0 and OpenID Connect flows. Usually, OAuth 2.0 clients are granted
// to applications that want to use OAuth 2.0 access and refresh tokens.
//
//
// In ORY Hydra, OAuth 2.0 clients are used to manage ORY Hydra itself. These clients may gain highly privileged access
// if configured that way. This endpoint should be well protected and only called by code you trust.
package client

// swagger:parameters createOAuthClient
// swagger:parameters createOAuth2Client
type swaggerCreateClientPayload struct {
// in: body
// required: true
Body Client
}

// swagger:parameters updateOAuthClient
// swagger:parameters updateOAuth2Client
type swaggerUpdateClientPayload struct {
// in: path
// required: true
Expand All @@ -20,13 +27,14 @@ type swaggerUpdateClientPayload struct {
}

// A list of clients.
// swagger:response clientsList
// swagger:response oAuth2ClientList
type swaggerListClientsResult struct {
// in: body
// type: array
Body []Client
}

// swagger:parameters getOAuthClient deleteOAuthClient
// swagger:parameters getOAuth2Client deleteOAuth2Client
type swaggerQueryClientPayload struct {
// The id of the OAuth 2.0 Client.
//
Expand Down
Loading