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

Dereference config schema and resolve issues #282

Merged
merged 9 commits into from
Oct 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,054 changes: 893 additions & 161 deletions .schemas/config.schema.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .schemas/pipeline/authenticators.anonymous.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authenticators.anonymous.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configAuthenticatorsAnonymous"
}
5 changes: 5 additions & 0 deletions .schemas/pipeline/authenticators.cookie_session.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authenticators.cookie_session.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configAuthenticatorsCookieSession"
}
5 changes: 5 additions & 0 deletions .schemas/pipeline/authenticators.jwt.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authenticators.jwt.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configAuthenticatorsJwt"
}
5 changes: 5 additions & 0 deletions .schemas/pipeline/authenticators.noop.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authenticators.noop.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configAuthenticatorsAnonymous"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authenticators.oauth2_client_credentials.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configAuthenticatorsOauth2ClientCredentials"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authenticators.oauth2_introspection.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configAuthenticatorsOauth2Introspection"
}
5 changes: 5 additions & 0 deletions .schemas/pipeline/authenticators.unauthorized.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authenticators.unauthorized.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configAuthenticatorsAnonymous"
}
4 changes: 4 additions & 0 deletions .schemas/pipeline/authorizers.allow.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authorizers.allow.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#"
}
4 changes: 4 additions & 0 deletions .schemas/pipeline/authorizers.deny.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authorizers.deny.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/authorizers.keto_engine_acp_ory.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configAuthorizersKetoEngineAcpOry"
}
5 changes: 5 additions & 0 deletions .schemas/pipeline/mutators.cookie.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/mutators.cookie.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configMutatorsCookie"
}
5 changes: 5 additions & 0 deletions .schemas/pipeline/mutators.header.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/mutators.header.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configMutatorsHeader"
}
5 changes: 5 additions & 0 deletions .schemas/pipeline/mutators.hydrator.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/mutators.hydrator.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configMutatorsHydrator"
}
5 changes: 5 additions & 0 deletions .schemas/pipeline/mutators.id_token.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/mutators.id_token.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/config.schema.json#/definitions/configMutatorsIdToken"
}
4 changes: 4 additions & 0 deletions .schemas/pipeline/mutators.noop.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/v0.32.1-beta.1/.schemas/mutators.noop.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#"
}
2 changes: 1 addition & 1 deletion docs/.oathkeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ authenticators:
# REQUIRED IF ENABLED - The OAuth 2.0 Client Secret to be used for the OAuth 2.0 Client Credentials Grant.
client_secret: some_secret

# REQUIRED IF ENABLED - The OAuth 2.0 Scope to be requested during the OAuth 2.0 Client Credentials Grant.
# The OAuth 2.0 Scope to be requested during the OAuth 2.0 Client Credentials Grant.
scope:
- foo
- bar
Expand Down
22 changes: 17 additions & 5 deletions driver/configuration/provider_viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,27 @@ func (v *ViperProvider) PipelineConfig(prefix, id string, override json.RawMessa
}
}

schema, err := schemas.Find(fmt.Sprintf("%s.%s.schema.json", prefix, id))
rawComponentSchema, err := schemas.Find(fmt.Sprintf("pipeline/%s.%s.schema.json", prefix, id))
if err != nil {
return errors.WithStack(err)
}

if result, err := gojsonschema.Validate(
gojsonschema.NewBytesLoader(schema),
gojsonschema.NewBytesLoader(marshalled),
); err != nil {
rawRootSchema, err := schemas.Find("config.schema.json")
if err != nil {
return errors.WithStack(err)
}

sbl := gojsonschema.NewSchemaLoader()
if err := sbl.AddSchemas(gojsonschema.NewBytesLoader(rawRootSchema)); err != nil {
return errors.WithStack(err)
}

schema, err := sbl.Compile(gojsonschema.NewBytesLoader(rawComponentSchema))
if err != nil {
return errors.WithStack(err)
}

if result, err := schema.Validate(gojsonschema.NewBytesLoader(marshalled)); err != nil {
return errors.WithStack(err)
} else if !result.Valid() {
return errors.WithStack(result.Errors())
Expand Down
2 changes: 1 addition & 1 deletion driver/configuration/provider_viper_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func TestAuthenticatorOAuth2TokenIntrospectionPreAuthorization(t *testing.T) {
{enabled: true, id: "a", secret: "b", turl: "", err: true},
{enabled: true, id: "", secret: "b", turl: "c", err: true},
{enabled: true, id: "a", secret: "", turl: "c", err: true},
{enabled: false, id: "a", secret: "b", turl: "c", err: false},
{enabled: false, id: "a", secret: "b", turl: "c", err: true},
{enabled: true, id: "a", secret: "b", turl: "https://some-url", err: false},
} {
t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/bxcodec/faker v2.0.1+incompatible
github.com/cenkalti/backoff v2.1.1+incompatible
github.com/codegangsta/negroni v1.0.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fsnotify/fsnotify v1.4.7
github.com/ghodss/yaml v1.0.0
Expand Down
8 changes: 8 additions & 0 deletions pipeline/authz/keto_engine_acp_ory.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,13 @@ func (a *AuthorizerKetoEngineACPORY) Config(config json.RawMessage) (*Authorizer
return nil, NewErrAuthorizerMisconfigured(a, err)
}

if c.RequiredAction == "" {
c.RequiredAction = "unset"
}

if c.RequiredResource == "" {
c.RequiredResource = "unset"
}

return &c, nil
}