Skip to content

Commit

Permalink
Fixes saml login flow to work with anonymous auth (#1839)
Browse files Browse the repository at this point in the history
* Fixes anonymous auth flow to work with SAML

Signed-off-by: Darshit Chanpura <[email protected]>

* Adds hardcoded credentials for anonymous user

Signed-off-by: Darshit Chanpura <[email protected]>

* Updates basic auth header to be a config constant

Signed-off-by: Darshit Chanpura <[email protected]>

* Removes unneeded usage of anonymous auth header constant

Signed-off-by: Darshit Chanpura <[email protected]>

* Updates logic to display anonymous auth login button

Signed-off-by: Darshit Chanpura <[email protected]>

* Adds test to check whether anonymous auth login button is displayed correctly

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes integrationtests

Signed-off-by: Darshit Chanpura <[email protected]>

* Adds integration tests for anonymous auth login with basic authorization header

Signed-off-by: Darshit Chanpura <[email protected]>

* Generates random password for anonymous user

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes lint errors

Signed-off-by: Darshit Chanpura <[email protected]>

* Adds saml auth header to differentiate saml requests

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes linter errors

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes basic auth tests

Signed-off-by: Darshit Chanpura <[email protected]>

* Removes console loggers

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes lint error

Signed-off-by: Darshit Chanpura <[email protected]>

* Addresses feedback

Signed-off-by: Darshit Chanpura <[email protected]>

* Resolves #1840

Signed-off-by: Darshit Chanpura <[email protected]>

* Replace magic value with constant

Signed-off-by: Darshit Chanpura <[email protected]>

* Renames query param and removes unused variables

Signed-off-by: Darshit Chanpura <[email protected]>

* Uses enum instead of magic constant

Signed-off-by: Darshit Chanpura <[email protected]>

* Extracts template function to a separate util file

Signed-off-by: Darshit Chanpura <[email protected]>

* Renames test

Signed-off-by: Darshit Chanpura <[email protected]>

* Removes unnecessary modifications required to solve this bug

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes import

Signed-off-by: Darshit Chanpura <[email protected]>

* Removes unused param

Signed-off-by: Darshit Chanpura <[email protected]>

* Removes unused method param

Signed-off-by: Darshit Chanpura <[email protected]>

* Removes incorrect method param

Signed-off-by: Darshit Chanpura <[email protected]>

---------

Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura authored Apr 12, 2024
1 parent 64995fc commit 681d1b1
Show file tree
Hide file tree
Showing 10 changed files with 517 additions and 42 deletions.
1 change: 1 addition & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const OPENID_AUTH_LOGIN_WITH_FRAGMENT = '/auth/openid/captureUrlFragment'
export const SAML_AUTH_LOGIN = '/auth/saml/login';
export const SAML_AUTH_LOGIN_WITH_FRAGMENT = '/auth/saml/captureUrlFragment';
export const ANONYMOUS_AUTH_LOGIN = '/auth/anonymous';
export const AUTH_TYPE_PARAM = 'auth_type';

export const OPENID_AUTH_LOGOUT = '/auth/openid/logout';
export const SAML_AUTH_LOGOUT = '/auth/saml/logout';
Expand Down
14 changes: 7 additions & 7 deletions public/apps/login/login-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ export function LoginPage(props: LoginPageDeps) {
</EuiFormRow>
);

if (authOpts.length > 1) {
if (props.config.auth.anonymous_auth_enabled) {
const anonymousConfig = props.config.ui[AuthType.ANONYMOUS].login;
formBody.push(
renderLoginButton(AuthType.ANONYMOUS, ANONYMOUS_AUTH_LOGIN, anonymousConfig)
);
}
if (props.config.auth.anonymous_auth_enabled) {
const anonymousConfig = props.config.ui[AuthType.ANONYMOUS].login;
formBody.push(
renderLoginButton(AuthType.ANONYMOUS, ANONYMOUS_AUTH_LOGIN, anonymousConfig)
);
}

if (authOpts.length > 1) {
formBody.push(<EuiSpacer size="xs" />);
formBody.push(<EuiHorizontalRule size="full" margin="xl" />);
formBody.push(<EuiSpacer size="xs" />);
Expand Down
Loading

0 comments on commit 681d1b1

Please sign in to comment.