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

SAML Integration for Login #434

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sourabhaggrawal
Copy link
Contributor

@sourabhaggrawal sourabhaggrawal commented Dec 9, 2021

Motivation

Idea is to support authentication from ThirdParty using SAML Approach. Changes are backward compatible and existing Login Approach using credentials will continue to work.

Provide Third Party Login Support Using SAML

Modifications

Changes to login with ThirdParty using SAML implementation.

Verifying this change

  • Make sure that the change passes the ./gradlew build checks.

@sourabhaggrawal
Copy link
Contributor Author

Hello @tuteng @eolivelli Please take a look, I will add test cases for same if changes good to you.

@shiv4289
Copy link

shiv4289 commented Dec 9, 2021

This is an important change for us. Pulsar manager not integrating with our SSO is a huge roadblock for pulsar manager adoption. Great work @sourabhaggrawal . Lets sprint to merge this quickly :-)

Copy link

@shiv4289 shiv4289 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sourabhaggrawal Left a few comments. Please check out.

@RequestMapping(value = "/sso", method = RequestMethod.POST)
@ResponseBody
public void loginByIDP(HttpServletRequest request, HttpServletResponse response) throws Exception {
String samlResponse = request.getParameter("SAMLResponse");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to check the call is a SAML response before using it.

Moreover, lets be neutral regarding the sso method here? The config and api endpoint are generic. The implementation assumes SAML. We should check the type of auth and switch to a branch of code (factory?) which gives us (authenticated / not authenticated) as a result.

String samlResponse = request.getParameter("SAMLResponse");
SAMLParser samlParser = new SAMLParser(certificate);
Map<String,String> userDetails = samlParser.getUserDetailsFromSAMLResponse(samlResponse);
Asserts.check(StringUtils.contains(userDetails.get("email"),whiteListedDomain),"Login with domain not supported");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to check the email format in string(using InternetAddress()?) in addition to the domain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering what we will achieve with the email format validation , the email is extracted from SAML Response which is served through IDP directly.

Copy link

@shiv4289 shiv4289 Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Lets drop this.

@@ -51,6 +51,7 @@ public void addInterceptors(InterceptorRegistry registry) {
.excludePathPatterns("/doc.html")
// BKVM
.excludePathPatterns("/bkvm")
.excludePathPatterns("/pulsar-manager/saml/**")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our endpoint is /sso right? Should this be /pulsar-manager/sso/**

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why ** ? can we do with just /sso without ** ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our endpoint is /saml/sso @shiv4289
here /saml is mapped at controller level and ** to exclude all method in that controller from authentication.
This makes me rethink to change the excludePathPatterns as /pulsar-manager/saml/sso to make only one method accessible without authentication.

@sama8
This comment was marked as off-topic.
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

Successfully merging this pull request may close these issues.

3 participants