[8.13] [kbn-test] remove deprecated auth route (#179561) (#179920)

# Backport

This will backport the following commits from `main` to `8.13`:
- [[kbn-test] remove deprecated auth route
(#179561)](https://github.com/elastic/kibana/pull/179561)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2024-04-03T11:59:40Z","message":"[kbn-test]
remove deprecated auth route (#179561)\n\n## Summary\r\n\r\nSince ms-104
was released, we no longer need to support both deprecated\r\nand new
cloud auth route.\r\n\r\nHow to test: run any FTR test with SAML auth
against MKI
project","sha":"e832852938a08cd95ad9e760a79a0184fcf23fea","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","FTR","v8.14.0","v8.13.1"],"title":"[kbn-test]
remove deprecated auth
route","number":179561,"url":"https://github.com/elastic/kibana/pull/179561","mergeCommit":{"message":"[kbn-test]
remove deprecated auth route (#179561)\n\n## Summary\r\n\r\nSince ms-104
was released, we no longer need to support both deprecated\r\nand new
cloud auth route.\r\n\r\nHow to test: run any FTR test with SAML auth
against MKI
project","sha":"e832852938a08cd95ad9e760a79a0184fcf23fea"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/179561","number":179561,"mergeCommit":{"message":"[kbn-test]
remove deprecated auth route (#179561)\n\n## Summary\r\n\r\nSince ms-104
was released, we no longer need to support both deprecated\r\nand new
cloud auth route.\r\n\r\nHow to test: run any FTR test with SAML auth
against MKI
project","sha":"e832852938a08cd95ad9e760a79a0184fcf23fea"}},{"branch":"8.13","label":"v8.13.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co>
This commit is contained in:
Kibana Machine 2024-04-03 09:38:12 -04:00 committed by GitHub
parent d0e6c3f9ea
commit dd3e76c2df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -73,8 +73,6 @@ const getCloudUrl = (hostname: string, pathname: string) => {
const createCloudSession = async (params: CreateSamlSessionParams) => {
const { hostname, email, password, log } = params;
// remove after ms-104 is released
const deprecatedLoginUrl = getCloudUrl(hostname, '/api/v1/users/_login');
const cloudLoginUrl = getCloudUrl(hostname, '/api/v1/saas/auth/_login');
let sessionResponse: AxiosResponse | undefined;
const requestConfig = (cloudUrl: string) => {
@ -93,22 +91,13 @@ const createCloudSession = async (params: CreateSamlSessionParams) => {
maxRedirects: 0,
};
};
try {
sessionResponse = await axios.request(requestConfig(deprecatedLoginUrl));
} catch (ex) {
log.error(`Failed to create the new cloud session with 'POST ${deprecatedLoginUrl}'`);
// no error on purpose
}
if (!sessionResponse || sessionResponse?.status === 404) {
// Retrying with new cloud login endpoint
try {
sessionResponse = await axios.request(requestConfig(cloudLoginUrl));
} catch (ex) {
log.error(`Failed to create the new cloud session with 'POST ${cloudLoginUrl}'`);
cleanException(cloudLoginUrl, ex);
throw ex;
}
try {
sessionResponse = await axios.request(requestConfig(cloudLoginUrl));
} catch (ex) {
log.error(`Failed to create the new cloud session with 'POST ${cloudLoginUrl}'`);
cleanException(cloudLoginUrl, ex);
throw ex;
}
const token = sessionResponse?.data?.token as string;