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

disable requested authentication context #5

Merged
merged 5 commits into from
Oct 1, 2018
Merged

disable requested authentication context #5

merged 5 commits into from
Oct 1, 2018

Conversation

Michael-372
Copy link
Contributor

@Michael-372 Michael-372 commented Sep 28, 2018

Passport saml sets a default authentication context of 'PasswordProtectedTransport'. There is some sort of bug with passport saml when trying to use this AuthnContext from a private internal network and authenticate with an external IDP. The proposed change her allows the developer to easily disable this authentication context and let the IDP determine the method of authentication.

With this change, simply add the following line to your configuration for apostrophe-saml inside of your Apostrophe app.js:

disableRequestedAuthnContext: true

Example:

'apostrophe-saml': {
issuer: 'mysite.com',
callbackUrl: 'mysite.com/callback',
disableRequestedAuthnContext: true
}

More details can be found here: https://github.com/bergie/passport-saml/issues/226

@boutell

Passport saml sets a default authentication context of 'PasswordProtectedTransport'. There is some sort of bug with passport saml when trying to use this AuthnContext from a private internal network and authenticate with an external IDP. The proposed change her allows the developer to easily disable this authentication context and let the IDP determine the method of authentication. 

With this change, simply add the following line to your configuration for apostrophe-saml inside of your Apostrophe app.js:

disableRequestedAuthnContext: true

Example:

'apostrophe-saml': {
  issuer: 'mysite.com',
  callbackUrl: 'mysite.com/callback',
  disableRequestedAuthnContext: true
}



More details can be found here: node-saml/passport-saml#226

@boutell
@boutell
Copy link
Contributor

boutell commented Sep 28, 2018 via email

@Michael-372
Copy link
Contributor Author

If your application requires a specific form of authentication context, particularly 'PasswordProtectedTransport' then you may want to keep this option set to false/null. However, if Apostrophe is not looking for this particular authentication context, then I guess you could always have it default to disabled within apostrophe-saml.

If a developer has a use case where they wanted to specify a different authentication context, then they may want to keep the context enabled and then specify a different context...though the ability to specify this alternate context is not reflected here.

My change above is a little bit basic in that it's either the passport-saml default 'PPT' context or let the IDP determine the context on it's own.

@Michael-372
Copy link
Contributor Author

Michael-372 commented Sep 28, 2018

apostrophe-saml wraps passport-saml in a pretty basic way which makes it very easy to set up with Apostrophe. However, we do lose access to a lot of configuration options with it's current form.

Ideally this extension would ultimately allow you to pass any of the passport saml configuration options through. But that may be asking for too much :-P

@boutell
Copy link
Contributor

boutell commented Sep 28, 2018 via email

@Michael-372
Copy link
Contributor Author

Michael-372 commented Sep 28, 2018

Well, we could always create an 'extraOptions' object. And then copy all attributes from extra options into the options object passed into passport saml.

This would allow apostrophe-saml to continue working with backwards compatible configurations

@boutell
Copy link
Contributor

boutell commented Sep 28, 2018 via email

@Michael-372
Copy link
Contributor Author

Sounds good. I will put something together for you to review.

Added the ability to use extra passport-saml options that were not previously defined in this wrapper. Previous configurations are untouched and should be backwards compatible. To pass extra options to apostrophe saml use the following syntax:
```
    'apostrophe-saml': {
      issuer: 'mysite.com',
      callbackUrl: 'mysite.com/callback',
      passportSamlOptions: {
        disableRequestedAuthnContext: true,
        logoutUrl: 'www.mysite.com/SLO',
        forceAuthn: true        
      }
    }
```
@Michael-372
Copy link
Contributor Author

@boutell

Ok take a look at my latest commit and let me know what you think.

Copy link
Contributor

@boutell boutell left a comment

Choose a reason for hiding this comment

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

We're getting close!

You should handle the overriding bit with _.defaults() or perhaps just Object.assign since all supported versions of Node support it. And follow the coding conventions of the module re: whitespace.

I think the most valuable contribution you might make here is adding a note to the README about how and why you might use this feature.

updated addPassportSamlOptions method to use Object.assign()
Readme updated to reflect new way of passing extra parameters to passport-saml through the passportSamlOptions object
@Michael-372
Copy link
Contributor Author

Michael-372 commented Sep 28, 2018

Thanks for the tip. I didn't know about Object.assign. That's very handy. I altered the method to use that instead of my barbaric C style for-loop ;-)

I also added the passportSamlOptions to the README.

Let me know if you need anything else.

@Michael-372
Copy link
Contributor Author

@boutell

This code is working in my own environment. Have you taken a look at the changes you requested?

@boutell boutell merged commit c0240e2 into apostrophecms-legacy:master Oct 1, 2018
@boutell
Copy link
Contributor

boutell commented Oct 1, 2018 via email

@Michael-372
Copy link
Contributor Author

No, thank you! And thanks for advocating a cleaner solution!

@Michael-372 Michael-372 deleted the patch-1 branch October 1, 2018 16:33
@boutell
Copy link
Contributor

boutell commented Oct 1, 2018 via email

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.

2 participants