-
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
Prepare the Security domain HTTP APIs for Serverless #162087
Changes from 25 commits
f7ba619
5203a0b
08146f0
c10abc7
dc727cd
70f06f7
8b0c93d
7a346b6
04f1c92
6c53a54
4f20016
a44549d
8f20ee0
994654c
aa8c78e
e4f60db
131a771
e3bb1be
8bb3ca2
074c0cc
2997135
78da626
ee8a12c
a366b54
6cb21ba
252cd72
d0b2364
452ad5a
d1c3bdf
a63d67b
14c00ae
9f0606d
ecb595c
4682542
182273f
e7eec38
0e43706
5e54975
f69ff2f
8018d63
cf5dae0
100ced7
b94cc86
0e291c6
3608f85
b81b484
3478460
24e21f4
95b2f12
1edb353
727b393
6ece943
761f23b
f0fbfdf
65c23e4
3c24c33
0d22303
5c535d6
a979e58
051cf71
4ca4924
305aa70
ba78385
d2ee490
c552a53
084e495
d0292f8
e8b0bef
5e953fa
573a552
710ca09
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 |
---|---|---|
|
@@ -32,9 +32,14 @@ export function defineCommonRoutes({ | |
basePath, | ||
license, | ||
logger, | ||
buildFlavor, | ||
}: RouteDefinitionParams) { | ||
// Generate two identical routes with new and deprecated URL and issue a warning if route with deprecated URL is ever used. | ||
for (const path of ['/api/security/logout', '/api/security/v1/logout']) { | ||
// For a serverless build, do not register deprecated versioned routes | ||
for (const path of [ | ||
'/api/security/logout', | ||
...(buildFlavor !== 'serverless' ? ['/api/security/v1/logout'] : []), | ||
]) { | ||
router.get( | ||
{ | ||
path, | ||
|
@@ -79,7 +84,11 @@ export function defineCommonRoutes({ | |
} | ||
|
||
// Generate two identical routes with new and deprecated URL and issue a warning if route with deprecated URL is ever used. | ||
for (const path of ['/internal/security/me', '/api/security/v1/me']) { | ||
// For a serverless build, do not register deprecated versioned routes | ||
for (const path of [ | ||
'/internal/security/me', | ||
...(buildFlavor !== 'serverless' ? ['/api/security/v1/me'] : []), | ||
]) { | ||
router.get( | ||
{ path, validate: false }, | ||
createLicensedRouteHandler((context, request, response) => { | ||
|
@@ -123,66 +132,68 @@ export function defineCommonRoutes({ | |
return undefined; | ||
} | ||
|
||
router.post( | ||
{ | ||
path: '/internal/security/login', | ||
validate: { | ||
body: schema.object({ | ||
providerType: schema.string(), | ||
providerName: schema.string(), | ||
currentURL: schema.string(), | ||
params: schema.conditional( | ||
schema.siblingRef('providerType'), | ||
schema.oneOf([ | ||
schema.literal(BasicAuthenticationProvider.type), | ||
schema.literal(TokenAuthenticationProvider.type), | ||
]), | ||
basicParamsSchema, | ||
schema.never() | ||
), | ||
}), | ||
if (buildFlavor !== 'serverless') { | ||
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 should provide developers with some escape hatch to log in to Kibana locally before we disable these APIs, otherwise they won't be able to use Kibana at all. What do you think? 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. Providing something like this could solve the issue brought up about how many tests are written (logging in as a user with specific privileges). Do you have any ideas how we could do that? |
||
router.post( | ||
{ | ||
path: '/internal/security/login', | ||
validate: { | ||
body: schema.object({ | ||
providerType: schema.string(), | ||
providerName: schema.string(), | ||
currentURL: schema.string(), | ||
params: schema.conditional( | ||
schema.siblingRef('providerType'), | ||
schema.oneOf([ | ||
schema.literal(BasicAuthenticationProvider.type), | ||
schema.literal(TokenAuthenticationProvider.type), | ||
]), | ||
basicParamsSchema, | ||
schema.never() | ||
), | ||
}), | ||
}, | ||
options: { authRequired: false }, | ||
}, | ||
options: { authRequired: false }, | ||
}, | ||
createLicensedRouteHandler(async (context, request, response) => { | ||
const { providerType, providerName, currentURL, params } = request.body; | ||
logger.info(`Logging in with provider "${providerName}" (${providerType})`); | ||
|
||
const redirectURL = parseNext(currentURL, basePath.serverBasePath); | ||
const authenticationResult = await getAuthenticationService().login(request, { | ||
provider: { name: providerName }, | ||
redirectURL, | ||
value: getLoginAttemptForProviderType(providerType, redirectURL, params), | ||
}); | ||
|
||
if (authenticationResult.redirected() || authenticationResult.succeeded()) { | ||
return response.ok({ | ||
body: { location: authenticationResult.redirectURL || redirectURL }, | ||
headers: authenticationResult.authResponseHeaders, | ||
createLicensedRouteHandler(async (context, request, response) => { | ||
const { providerType, providerName, currentURL, params } = request.body; | ||
logger.info(`Logging in with provider "${providerName}" (${providerType})`); | ||
|
||
const redirectURL = parseNext(currentURL, basePath.serverBasePath); | ||
const authenticationResult = await getAuthenticationService().login(request, { | ||
provider: { name: providerName }, | ||
redirectURL, | ||
value: getLoginAttemptForProviderType(providerType, redirectURL, params), | ||
}); | ||
} | ||
|
||
return response.unauthorized({ | ||
body: authenticationResult.error, | ||
headers: authenticationResult.authResponseHeaders, | ||
}); | ||
}) | ||
); | ||
|
||
router.post( | ||
{ path: '/internal/security/access_agreement/acknowledge', validate: false }, | ||
createLicensedRouteHandler(async (context, request, response) => { | ||
// If license doesn't allow access agreement we shouldn't handle request. | ||
if (!license.getFeatures().allowAccessAgreement) { | ||
logger.warn(`Attempted to acknowledge access agreement when license doesn't allow it.`); | ||
return response.forbidden({ | ||
body: { message: `Current license doesn't support access agreement.` }, | ||
if (authenticationResult.redirected() || authenticationResult.succeeded()) { | ||
return response.ok({ | ||
body: { location: authenticationResult.redirectURL || redirectURL }, | ||
headers: authenticationResult.authResponseHeaders, | ||
}); | ||
} | ||
|
||
return response.unauthorized({ | ||
body: authenticationResult.error, | ||
headers: authenticationResult.authResponseHeaders, | ||
}); | ||
} | ||
}) | ||
); | ||
|
||
router.post( | ||
{ path: '/internal/security/access_agreement/acknowledge', validate: false }, | ||
createLicensedRouteHandler(async (context, request, response) => { | ||
// If license doesn't allow access agreement we shouldn't handle request. | ||
if (!license.getFeatures().allowAccessAgreement) { | ||
logger.warn(`Attempted to acknowledge access agreement when license doesn't allow it.`); | ||
return response.forbidden({ | ||
body: { message: `Current license doesn't support access agreement.` }, | ||
}); | ||
} | ||
|
||
await getAuthenticationService().acknowledgeAccessAgreement(request); | ||
await getAuthenticationService().acknowledgeAccessAgreement(request); | ||
|
||
return response.noContent(); | ||
}) | ||
); | ||
return response.noContent(); | ||
}) | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,10 @@ export function defineAuthenticationRoutes(params: RouteDefinitionParams) { | |
defineSAMLRoutes(params); | ||
} | ||
|
||
if (params.config.authc.sortedProviders.some(({ type }) => type === 'oidc')) { | ||
if ( | ||
params.buildFlavor !== 'serverless' && | ||
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. It's not necessary to make a build flavor check here because OIDC is not configured in serverless, but should have one anyway for good measure? 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. I'm not sure, I'd probably just keep |
||
params.config.authc.sortedProviders.some(({ type }) => type === 'oidc') | ||
) { | ||
defineOIDCRoutes(params); | ||
} | ||
} |
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.
This will be present once #162149 is merged to main.
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.
Aaaand, it has been merged!
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.
And reverted .... https://github.com/elastic/kibana/pull/163296/files
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.
The revert was closed and not merged.