Skip to content

Commit

Permalink
feat: add loginUrlCredentials config (#110)
Browse files Browse the repository at this point in the history
allow an optional loginUrlCredentials config which provides basic authentication credentials when
visiting loginUrl

Co-authored-by: Greg Remiasz <grzegorz.remiasz@latimes.com>
  • Loading branch information
gremz and Greg Remiasz committed Dec 10, 2021
1 parent 35e9ae0 commit 60fe485
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Options passed to the task include:
| username | |
| password | |
| loginUrl | The URL for the login page that includes the social network buttons | https://www.example.com/login |
| loginUrlCredentials | Basic Authentication credentials for the `loginUrl` | `{username: user, password: demo}` |
| args | string array which allows providing further arguments to puppeteer | `['--no-sandbox', '--disable-setuid-sandbox']` |
| headless | Whether to run puppeteer in headless mode or not | true |
| logs | Whether to log interaction with the loginUrl website & cookie data | false |
Expand Down
5 changes: 4 additions & 1 deletion src/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const fs = require('fs')
* @param {options.username} string username
* @param {options.password} string password
* @param {options.loginUrl} string password
* @param {options.loginUrlCredentials} Object Basic Authentication credentials for the `loginUrl`
* @param {options.args} array[string] string array which allows providing further arguments to puppeteer
* @param {options.loginSelector} string a selector on the loginUrl page for the social provider button
* @param {options.loginSelectorDelay} number delay a specific amount of time before clicking on the login button, defaults to 250ms. Pass a boolean false to avoid completely.
Expand Down Expand Up @@ -199,7 +200,9 @@ async function baseLoginConnect(
await page.setUserAgent(
'Mozilla/5.0 (Windows NT 10.0 Win64 x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36'
)

if (options.loginUrlCredentials) {
await page.authenticate(options.loginUrlCredentials)
}
await page.goto(options.loginUrl)
await login({page, options})

Expand Down

0 comments on commit 60fe485

Please sign in to comment.