Skip to content

Commit 4095559

Browse files
committed
first commit
0 parents  commit 4095559

21 files changed

+16278
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#root = true
2+
3+
[*]
4+
indent_style = space
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
max_line_length = 100
10+
indent_size = 2
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
coverage
3+
.nyc_output
4+
.DS_Store
5+
*.log
6+
.vscode
7+
.idea
8+
dist
9+
compiled
10+
.awcache
11+
.rpt2_cache
12+
docs

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: node_js
2+
cache:
3+
directories:
4+
- ~/.npm
5+
notifications:
6+
email: false
7+
node_js:
8+
- '10'
9+
- '11'
10+
- '8'
11+
- '6'
12+
script:
13+
- npm run test:prod && npm run build
14+
after_success:
15+
- npm run travis-deploy-once "npm run report-coverage"
16+
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run deploy-docs"; fi
17+
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run semantic-release"; fi
18+
branches:
19+
except:
20+
- /^v\d+\.\d+\.\d+$/

CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
We're really glad you're reading this, because we need volunteer developers to help this project come to fruition. 👏
2+
3+
## Instructions
4+
5+
These steps will guide you through contributing to this project:
6+
7+
- Fork the repo
8+
- Clone it and install dependencies
9+
10+
git clone https://github.com/skogsmaskin/passport-netlify
11+
npm install
12+
13+
Make and commit your changes. Make sure the commands npm run build and npm run test:prod are working.
14+
15+
Finally send a [GitHub Pull Request](https://github.com/skogsmaskin/passport-netlify/compare?expand=1) with a clear list of what you've done (read more [about pull requests](https://help.github.com/articles/about-pull-requests/)). Make sure all of your commits are atomic (one feature per commit).

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2017 Per-Kristian Nordnes <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# passport-netlify
2+
3+
[Passport](http://passportjs.org/) strategy for authenticating with
4+
[Netlify](https://www.netlify.com/) using the OAuth 2.0 API.
5+
6+
This module lets you authenticate with Netlify in your Node.js applications.
7+
By plugging into Passport, Netlify authentication can be easily and
8+
unobtrusively integrated into any application or framework that supports
9+
[Connect](http://www.senchalabs.org/connect/)-style middleware, including
10+
[Express](http://expressjs.com/).
11+
12+
13+
## Install
14+
15+
```bash
16+
$ npm install passport-netlify
17+
```
18+
19+
## Usage
20+
21+
#### Create an Application
22+
23+
Before using `passport-netlify`, you must register an application with Netlify.
24+
If you have not already done so, a new application can be created at
25+
[OAuth applications](https://app.netlify.com/account/applications) within
26+
your Netlify account settings panel. Your application will be issued a
27+
client ID and client secret, which need to be provided to the strategy.
28+
You will also need to configure a callback URL which matches the route in your application.
29+
30+
#### Configure Strategy
31+
32+
The Netlify authentication strategy authenticates users using a Netlify account
33+
and OAuth 2.0 tokens. The client ID and secret obtained when creating an
34+
application are supplied as options when creating the strategy. The strategy
35+
also requires a `verify` callback, which receives the access token and optional
36+
refresh token, as well as `profile` which contains the authenticated user's
37+
Netilify profile. The `verify` callback must call `cb` providing a user to
38+
complete authentication.
39+
40+
```js
41+
const NetlifyStrategy = require('passport-netlify').Strategy;
42+
43+
passport.use(new NetlifyStrategy({
44+
clientID: NETLIFY_CLIENT_ID,
45+
clientSecret: NETLIFY_CLIENT_SERET,
46+
callbackURL: "http://127.0.0.1:3000/auth/netlify/callback",
47+
state: true // use OAuth2 state param to protect against csrf attacks
48+
},
49+
(accessToken, refreshToken, profile, cb) => {
50+
User.findOrCreate({provider: 'netlify': providerId: profile.id }, (err, user) => {
51+
return cb(err, user)
52+
})
53+
}
54+
))
55+
```
56+
57+
*Note: While Netlify doesn't support refresh tokens (as for Jan. 2019), the verify
58+
callback still uses a second parameter `refreshToken` to conform to the OAuth2 standard. This makes it easier to
59+
share a verify callback function for all `passport-oauth2` based authentications you use with Passport.js. The `refreshToken` will be undefined with this strategy, and should just be ignored.*
60+
61+
#### Authenticate Requests
62+
63+
Use `passport.authenticate()`, specifying the `'netlify'` strategy, to
64+
authenticate requests.
65+
66+
For example, as route middleware in an [Express](http://expressjs.com/)
67+
application:
68+
69+
```js
70+
app.get('/auth/netlify', passport.authenticate('netlify'))
71+
72+
app.get('/auth/netlify/callback',
73+
passport.authenticate('netlify', { failureRedirect: '/login' }),
74+
(req, res) => {
75+
// Successful authentication, redirect home.
76+
res.redirect('/');
77+
})
78+
```

code-of-conduct.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [http://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: http://contributor-covenant.org
74+
[version]: http://contributor-covenant.org/version/1/4/

0 commit comments

Comments
 (0)