Skip to content
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

Make it easier to debug SAML errors #66

Open
Nikschavan opened this issue Dec 1, 2020 · 0 comments
Open

Make it easier to debug SAML errors #66

Nikschavan opened this issue Dec 1, 2020 · 0 comments

Comments

@Nikschavan
Copy link

Recently I had to debug SSO errors where users were seeing 500 errors because of some infra configuration errors, but debugging this was very difficult as I had to figure out and spend some time to get some logging setup.

The way I did was to add logging into X-ray with more details for the error from $saml->getLastErrorReason() and $saml->getLastErrorException()

function get_sso_user() {
$saml = instance();
try {
$saml->processResponse();
} catch ( \Exception $e ) {
/* translators: %s = error message */
return new \WP_Error( 'invalid-saml', sprintf( esc_html__( 'Error: Could not parse the authentication response, please forward this error to your administrator: "%s"', 'wp-simple-saml' ), esc_html( $e->getMessage() ) ) );
}
if ( ! empty( $saml->getErrors() ) ) {
$errors = implode( ', ', $saml->getErrors() );
/* translators: %s = error message */
return new \WP_Error( 'invalid-saml', sprintf( esc_html__( 'Error: Could not parse the authentication response, please forward this error to your administrator: "%s"', 'wp-simple-saml' ), esc_html( $errors ) ) );
}
if ( ! $saml->isAuthenticated() ) {
return new \WP_Error( 'not-authenticated', esc_html__( 'Error: Authentication wasn\'t completed successfully.', 'wp-simple-saml' ) );
}
return get_or_create_wp_user( $saml );
}

I am thinking about how we can make it easier to debug this, One of the simplest solutions I am thinking of is to also trigger WordPress actions with related information and let the application code handle different logging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant