-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Switch Kerberos authentication provider to a dedicated _kerberos
grant. Introduce Tokens
for common access/refresh token tasks.
#39366
Changes from 2 commits
5fdd55b
9353068
bec52bc
977c132
635a86d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,21 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { stub } from 'sinon'; | ||
import { stub, createStubInstance } from 'sinon'; | ||
import { Tokens } from '../tokens'; | ||
import { AuthenticationProviderOptions } from './base'; | ||
|
||
export function mockAuthenticationProviderOptions( | ||
providerOptions: Partial<AuthenticationProviderOptions> = {} | ||
providerOptions: Partial<Pick<AuthenticationProviderOptions, 'basePath'>> = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: we don't need anything except for |
||
) { | ||
const client = { callWithRequest: stub(), callWithInternalUser: stub() }; | ||
const log = stub(); | ||
|
||
return { | ||
client: { callWithRequest: stub(), callWithInternalUser: stub() }, | ||
log: stub(), | ||
client, | ||
log, | ||
basePath: '/base-path', | ||
tokens: createStubInstance(Tokens), | ||
...providerOptions, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { Legacy } from 'kibana'; | |
import { AuthenticationResult } from '../authentication_result'; | ||
import { DeauthenticationResult } from '../deauthentication_result'; | ||
import { LoginAttempt } from '../login_attempt'; | ||
import { Tokens } from '../tokens'; | ||
|
||
/** | ||
* Describes a request complemented with `loginAttempt` method. | ||
|
@@ -23,6 +24,7 @@ export interface AuthenticationProviderOptions { | |
basePath: string; | ||
client: Legacy.Plugins.elasticsearch.Cluster; | ||
log: (tags: string[], message: string) => void; | ||
tokens: PublicMethodsOf<Tokens>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: relying on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels similar to what you have to do in Java/C# when you extract an interface that only has the public properties for the sake of testing. What you have here seems less intrusive, and makes me wonder if it's a pattern that we should embrace more widely? I have a bad habit of pretending that TS is more similar to the type systems in Java/C# than it really is, so it's great learning techniques like these from you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In a NP world we won't have too many of these cases (contracts are usually plain objects with public only stuff on them, that's is trivial to mock and work with without additional TS voodoo), hopefully, but in places where we still want something like this I believe we embrace this approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the core has the same problems. We pass around ES6 classes and later in tests have type errors passing POJO with the same interface. We haven't decided on the official solution in the core #33396 |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note:
basic
is the only provider that doesn't use tokens and it's pretty cheap to instantiate it even ifbasic
provider is used, so I decided to have it as provider option instead of re-creating it for every provider that uses tokens.