This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Steps for Heroku deployment #5
Open
lekkimworld
wants to merge
11
commits into
forcedotcom:master
Choose a base branch
from
lekkimworld:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
46563ff
Add steps for deployment to Heroku
lekkimworld d117b3e
Remove unused import and make Syncing.. into Syncing...
lekkimworld 525d702
README clarifications
lekkimworld 5ba9b3b
Ignore my steps
lekkimworld add05d5
Add question for custom objects using filter
lekkimworld 9e657a9
Update name of question
lekkimworld 64c45cb
Moved where filter was applied
lekkimworld f511032
Swap params
lekkimworld 07048d2
Update size
lekkimworld 049e531
Update totalSize as well
lekkimworld b24c1ab
Add question for custom objects with FILTER_NAMESPACE from env
lekkimworld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules | |
npm-debug.log | ||
.DS_Store | ||
.env | ||
my_steps.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ The application requires: | |
- `CORP_DOMAIN` is your corporate domain (i.e.: mycompany.com) used to identify Salesforce users without corporate email | ||
- `COOKIE_SECRET` is a secret used to sign the session cookie | ||
- `ADMIN_TOKEN` is a secret used to edit/delete Org information such as name or description | ||
- `ENCRYPTION_KEY` is a hex string representing 32 random bytes, used to encrypt/decrypt the Oauth refresh tokens (AES 256) | ||
- `ENCRYPTION_KEY` is 32 random bytes (**Please Note:** MUST be hex encoded), used to encrypt/decrypt the Oauth refresh tokens (AES 256) | ||
3. Install Node.js dependencies through Yarn, with `yarn install` | ||
4. Run the server with `node server.js`, confirm you see the `App listening on port 3000` message in the console | ||
5. Load `http://localhost:3000/setup`, confirm you see the `Successfully setup DB` message in the console | ||
|
@@ -61,7 +61,122 @@ When ready for production deployment: | |
- `SAML_ENTRY_POINT` | ||
- `SAML_ISSUER` | ||
- `SAML_CALLBACK` | ||
- `SAML_CERT` | ||
- `SAML_CERT` (maps to the 'cert' configuration parameter: *"Identity Provider's public PEM-encoded X.509 signing certificate using the cert confguration key. The "BEGIN CERTIFICATE" and "END CERTIFICATE" lines should be stripped out and the certificate should be provided on a single line."*) | ||
|
||
### Deployment to Heroku | ||
Below are complete steps to deploy the application on Heroku. If you do not have a Heroku account head over to https://signup.heroku.com to create an account first. Once you have an account ensure you have the Heroku CLI (command line interface) installed (see https://devcenter.heroku.com/articles/heroku-cli). The below steps walks through setting up Org Monitor with a Developer Org but the steps applies equally well to a Production org. | ||
|
||
#### Clone Git Repo and Create App | ||
```bash | ||
# clone repo | ||
$ git clone [email protected]:forcedotcom/OrgMonitor.git | ||
$ cd OrgMonitor | ||
|
||
# create app (also sets git remote) | ||
$ heroku apps:create --region eu | ||
|
||
# get appname from git remote | ||
$ APP_NAME=`git remote get-url heroku | cut -d'/' -f4 | cut -d'.' -f1` | ||
$ echo $APP_NAME | ||
funky-medina-23982 | ||
``` | ||
|
||
*Please Note:* Below I simply use funky-medina-23982 to refer to the app on Heroku i.e. what the APP_NAME variable contains now. | ||
|
||
#### Create Connected App in Salesforce | ||
1. Open Salesforce Setup | ||
2. Search for "App Manager" | ||
3. Click "New Connected App" and fill in | ||
- Connected App Name | ||
- API Name | ||
- Contact Email | ||
4. Check "Enable OAuth Settings" | ||
5. Set "Callback URL" to https://funky-medina-23982.herokuapp.com/callback (replace with actual app name) | ||
6. Select the following OAuth Scopes: | ||
- Access and manage your data (api) | ||
- Perform requests on your behalf at any time (refresh_token, offline_access) | ||
7. Save to close | ||
|
||
#### Gather Info (to replace below) | ||
1. Reopen the Connected app and note down the "Consumer Key" (`CLIENT_ID`) and "Consumer Secret" (`CLIENT_SECRET`)) | ||
2. Hex encode 32 characters of random characters (http://www.convertstring.com/EncodeDecode/HexEncode) (`ENCRYPTION_KEY`) | ||
3. Create yourself a password for `ADMIN_TOKEN` | ||
4. Create yourself a password for `COOKIE_SECRET` | ||
|
||
#### Configure Heroku app, push source and open | ||
```bash | ||
# create addons and set config | ||
heroku addons:create mongolab:sandbox | ||
heroku addons:create heroku-postgresql:hobby-dev | ||
heroku config:set CLIENT_ID=foo | ||
heroku config:set CLIENT_SECRET=bar | ||
heroku config:set REDIRECT_URI=https://$APP_NAME.herokuapp.com/callback | ||
heroku config:set CORP_DOMAIN=lekkimworld.com | ||
heroku config:set COOKIE_SECRET=baz | ||
heroku config:set ADMIN_TOKEN=gaz | ||
heroku config:set ENCRYPTION_KEY=3242384142324532343230334337313636384446313944453334394630334436 | ||
heroku config:set NODE_ENV=development | ||
|
||
# push app source to Heroku | ||
git push heroku master | ||
|
||
# start worker dyno | ||
heroku ps:scale -a $APP_NAME worker=1:free | ||
|
||
# load /setup to configure app | ||
curl https://$APP_NAME.herokuapp.com/setup | ||
|
||
# restart app | ||
heroku restart -a $APP_NAME | ||
|
||
# open app in browser | ||
open https://$APP_NAME.herokuapp.com | ||
``` | ||
|
||
#### Test it out! | ||
Now is a good time to ensure you can open the app in the browser. From here either follow the next section on how to configure SAML for authentication or skip it to move to adding an org to OrgMonitor. | ||
|
||
#### My Domain and SAML | ||
1. In Salesforce Setup enable My Domain and deploy to all users (if not enabled). Note down the custom domain you've chosen. Below I use `demoitout.my.salesforce.com` (see when I set SAML_ENTRY_POINT) | ||
2. Search for "Identity Provider" in Setup and ensure Identity Provider is enabled | ||
3. Search for "Single Sign-On Setings" in Setup and open | ||
4. Ensure "SAML Enabled" is checked | ||
5. Open the Connected App you created earlier | ||
6. Check "Enable SAML" | ||
7. Fill in | ||
- Entity Id: "funky-medina-23982" (use actual app name) | ||
- ACS URL: https://funky-medina-23982.herokuapp.com/login/callback | ||
8. Save to close | ||
|
||
```bash | ||
# configure app to use SAML for login | ||
heroku config:set SAML_CALLBACK=https://$APP_NAME.herokuapp.com/login/callback | ||
heroku config:set SAML_ISSUER=$APP_NAME | ||
heroku config:set SAML_CERT=MIIErDCCA...96TOK7Ph | ||
heroku config:set SAML_ENTRY_POINT=https://demoitout.my.salesforce.com/idp/endpoint/HttpRedirect | ||
|
||
# set NODE_ENV to production to require authentication | ||
heroku config:set -a $APP_NAME NODE_ENV=production | ||
|
||
# open app to ensure it requires to to authenticate | ||
open https://$APP_NAME.herokuapp.com | ||
``` | ||
|
||
#### Create Salesforce user and Profile | ||
1. Open Salesforce Setup | ||
2. Clone the "Standard User" Profile and call it "Org Monitor" (or what ever you wish) and remove all rights, CRUD access etc. Now check the following permissions: | ||
- `API Enabled` | ||
- `View All Users` | ||
- `View Health Check` | ||
- `View Setup and Configuration` | ||
3. Ensure the Profile allows access to the Connected App you created | ||
4. Save the Profile | ||
5. Create a new user assigning the Profile you just created. Remove all rights. Login as the created user using the reset-link as normal. | ||
|
||
#### Add org to OrgMonitor | ||
1. Open the app to /add/prod to add a Production / Developer org (using https://login.salesforce.com for login) or /add/sandbox to add a Sandbox org (using https://test.salesforce.com for login) | ||
2. Perform OAuth authorization | ||
3. Ensure org shows up in OrgMonitor with data | ||
|
||
## License | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can elaborate on this further? Where does this token get input?