-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
375 additions
and
324 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
51 changes: 51 additions & 0 deletions
51
x-pack/plugins/security/public/authentication/capture_url/capture_url_app.ts
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,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CoreSetup, HttpSetup } from 'src/core/public'; | ||
import { SessionInfo } from '../../../common/types'; | ||
|
||
interface CreateDeps { | ||
application: CoreSetup['application']; | ||
http: HttpSetup; | ||
} | ||
|
||
export const captureURLApp = Object.freeze({ | ||
id: 'security_capture_url', | ||
create({ application, http }: CreateDeps) { | ||
http.anonymousPaths.register('/internal/security/capture-url'); | ||
application.register({ | ||
id: this.id, | ||
title: '', | ||
chromeless: true, | ||
appRoute: '/internal/security/capture-url', | ||
async mount() { | ||
try { | ||
const { provider } = await http.get<SessionInfo>('/internal/security/session'); | ||
if (!provider) { | ||
throw new Error('Cannot retrieve current provider.'); | ||
} | ||
|
||
const { location } = await http.post<{ location: string }>( | ||
'/internal/security/login_with', | ||
{ | ||
body: JSON.stringify({ | ||
providerType: provider.type, | ||
providerName: provider.name, | ||
currentURL: window.location.href, | ||
}), | ||
} | ||
); | ||
|
||
window.location.href = location; | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
|
||
return () => {}; | ||
}, | ||
}); | ||
}, | ||
}); |
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/security/public/authentication/capture_url/index.ts
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,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { captureURLApp } from './capture_url_app'; |
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
Oops, something went wrong.