Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

passport-sf-signed-post-request

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-sf-signed-post-request

passport implementation of salesforce signed post request authentication for use in salesforce canvas apps

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Passport SF Signed Post Request

Provides a strategy implementation for passport for Salesforce's canvas app signed post request authentication mechanism. This strategy is meant to be used with a cookie based user session and a server side session store such as redistogo

To use this authentication strategy you need a salesforce instance. You can sign up for a free edition for development at https://developer.salesforce.com/

Once you have your salesforce instance you can create canvas app by going to Setup > App Manager and clicking the New Connected App

In the canvas app:

  1. make sure that Oauth Settings are enabled for the connected app oauth settings
  2. make sure Canvas App Settings are enabled and select Signed Request (POST) as the Access Method canvas settings
  3. save the connected app then click the Manage button. Ensure that in OAuth Policies "Permitted Users" is set to "Admin approved users are pre-authorized" NOTE that if your org is setup with API Access Control enabled the app will show "Admin approved users are pre-authorized" and it won't be editible. Don't be fooled it isn't actually set to that you'll need to disable API Access Control temporarily and when you go back to the policy settings of your connected app you'll see that is in fact set to allow users to self authorize. Change it and save, then you can turn API Access Control back on

You can checkout out an example express app that uses the passport strategy here

https://github.com/atnmorrison/canvasexample1/

The strategy takes the salesforce secret and optionally a callback function to setup the session. The callback function receives the sr (signed request) and the req object so that anything that needs to be done after login can be executed such as setting up session variables for example below the sr is assigned to a session variable for later use

passport.use('sf-signed-post-request', new sfsprStrategy(process.env.CANVAS_SECRET, function(sr, req){
    req.session.sr = sr; 
}));

Note that for it to run locally you'll need to create a security folder in your forked project with a self signed certificate for SSL. The reason for this is that for canvas to work you need your cookie to use sameSite: "none", and to use that you must use a secure cookie, and to use a secure cookie you must use SSL.

You can follow the excellent instructions to get it up and running in the top answer of this stack overflow

https://stackoverflow.com/questions/21397809/create-a-trusted-self-signed-ssl-cert-for-localhost-for-use-with-express-node

Keywords

FAQs

Package last updated on 12 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc