forked from ory/oathkeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Problem Summary This merge request addresses issue !669 surrounding the behavior of the "noop" authentication method, which underwent changes in commit 6f8ab4f. Reverting these changes to restore the previous behavior is challenging due to the potential for breaking existing systems. To mitigate this risk, we propose implementing a new authenticator named "delegate" to replicate the original behavior of the "noop" method. ## Ideal Solution To address this issue, our proposed solution is to implement a new authenticator named "delegate" that replicates the original behavior of the "noop" method. This approach ensures that existing systems in production remain stable and unaffected by changes, while also providing users who prefer the old behavior with an option to utilize it. By introducing the "delegate" authenticator, we mitigate the risk of breaking changes while offering flexibility to users who require the previous behavior. ## Changes Proposed 1. **New Authenticator Module**: This MR adds a new authenticator module named "delegate" to replicate the original behavior of the "noop" method. 3. **Integration Tests**: Integration tests will be added to validate the functionality of the "delegate" authenticator, ensuring compatibility and reliability. 4. **Documentation Updates**: Documentation will be updated to include details about the new "delegate" authenticator, its configuration options, and usage examples. ## Related Issues ory#1152 ory#669 closes 1152
- Loading branch information
1 parent
817943a
commit 55254d1
Showing
19 changed files
with
311 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"$id": "https://raw.githubusercontent.com/ory/oathkeeper/master/.schemas/authenticators.delegate.schema.json", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"title": "Delegate Authenticator Configuration", | ||
"description": "This section is optional when the authenticator is disabled.", | ||
"properties": {}, | ||
"additionalProperties": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright © 2023 Ory Corp | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package authn | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
|
||
"github.com/ory/oathkeeper/driver/configuration" | ||
"github.com/ory/oathkeeper/pipeline" | ||
) | ||
|
||
type AuthenticatorDelegate struct { | ||
c configuration.Provider | ||
} | ||
|
||
func NewAuthenticatorDelegate(c configuration.Provider) *AuthenticatorDelegate { | ||
return &AuthenticatorDelegate{c: c} | ||
} | ||
|
||
func (a *AuthenticatorDelegate) GetID() string { | ||
return "delegate" | ||
} | ||
|
||
func (a *AuthenticatorDelegate) Validate(config json.RawMessage) error { | ||
if !a.c.AuthenticatorIsEnabled(a.GetID()) { | ||
return NewErrAuthenticatorNotEnabled(a) | ||
} | ||
|
||
if err := a.c.AuthenticatorConfig(a.GetID(), config, nil); err != nil { | ||
return NewErrAuthenticatorMisconfigured(a, err) | ||
} | ||
return nil | ||
} | ||
|
||
func (a *AuthenticatorDelegate) Authenticate(r *http.Request, session *AuthenticationSession, config json.RawMessage, _ pipeline.Rule) error { | ||
return ErrAuthenticatorDelegate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright © 2023 Ory Corp | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package authn_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ory/oathkeeper/driver/configuration" | ||
"github.com/ory/oathkeeper/internal" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAuthenticatorDelegate(t *testing.T) { | ||
t.Parallel() | ||
conf := internal.NewConfigurationWithDefaults() | ||
reg := internal.NewRegistry(conf) | ||
|
||
a, err := reg.PipelineAuthenticator("delegate") | ||
require.NoError(t, err) | ||
assert.Equal(t, "delegate", a.GetID()) | ||
|
||
t.Run("method=authenticate", func(t *testing.T) { | ||
err := a.Authenticate(nil, nil, nil, nil) | ||
require.Error(t, err) | ||
}) | ||
|
||
t.Run("method=validate", func(t *testing.T) { | ||
conf.SetForTest(t, configuration.AuthenticatorDelegateIsEnabled, true) | ||
require.NoError(t, a.Validate(nil)) | ||
|
||
conf.SetForTest(t, configuration.AuthenticatorDelegateIsEnabled, false) | ||
require.Error(t, a.Validate(nil)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.