Authn: Add client for api keys (#60339)

* AuthN: Add functionallity to test if auth client should be used

* AuthN: Add bolierplate client for api keys and register it

* AuthN: Add tests for api key client

* Inject service

* AuthN: Update client names

* ContextHandler: Set authn service

* AuthN: Implement authentication for api key client

* ContextHandler: Use authn service for api keys if flag is enabled

* AuthN: refactor authentication method to return additional value to
indicate if client could perform authentication

* update prefixes

* Add namespaced id to identity

* AuthN: Expand the Identity struct to include required fields from signed
in user

* Add error for disabled service account

* Add function to write error response based on errutil.Error

* Add error to log

* Return errors based on errutil.Error

* pass error

* update log message

* Fix namespaced ids

* Add tests

* Lint
This commit is contained in:
Karl Persson
2022-12-19 09:22:11 +01:00
committed by GitHub
parent cc4d18f626
commit 2e53a58bc3
9 changed files with 572 additions and 36 deletions

View File

@@ -14,9 +14,14 @@ var _ authn.Client = new(FakeClient)
type FakeClient struct {
ExpectedErr error
ExpectedTest bool
ExpectedIdentity *authn.Identity
}
func (f *FakeClient) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) {
return f.ExpectedIdentity, f.ExpectedErr
}
func (f *FakeClient) Test(ctx context.Context, r *authn.Request) bool {
return f.ExpectedTest
}