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

Add Prettier for style formatting #112

Merged
merged 2 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 14 additions & 33 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
{
"env": {
"es6": true,
"node": true,
"mocha": true
},
"extends": "eslint:recommended",
"rules": {
"no-useless-escape": 1,
"no-console": 0,
"indent": [
"error",
2,
{ "SwitchCase": 1 }
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't need formatting rules as prettier will handle this

"error",
"single",
{
"avoidEscape": true
}
],
"semi": [
"error",
"always"
]
},
"parserOptions": {
"ecmaVersion": 2018
}
"env": {
"es6": true,
"node": true,
"mocha": true
},
"extends": "eslint:recommended",
"rules": {
"no-useless-escape": 1,
"no-console": 0,
"linebreak-style": ["error", "unix"]
},
"parserOptions": {
"ecmaVersion": 2018
}
}
2 changes: 1 addition & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ staleLabel: closed:stale

# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CHANGELOG.md
coverage
.nyc_output
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same config as auth0.js, spa js, auth0-react etc..

"singleQuote": true,
"printWidth": 80
}
22 changes: 12 additions & 10 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The `auth()` middleware has a few configuration properties that are required for

- **`secret`** - The secret used to derive various keys utilized by the library for signing, encryption, etc. It must be a string, buffer, or an array of strings or buffers. When an array is provided, the first member is used for current operations while the other array members are used for decrypting/verifying old cookies, this enables secret rotation. This can be set automatically with a `SECRET` variable in your environment.
- **`baseURL`** - The root URL for the application router. This can be set automatically with a `BASE_URL` variable in your environment.
- **`clientID`** - The Client ID for your application. This can be set automatically with a `CLIENT_ID` variable in your environment.
- **`clientID`** - The Client ID for your application. This can be set automatically with a `CLIENT_ID` variable in your environment.
- **`issuerBaseURL`** - The root URL for the token issuer with no trailing slash. In Auth0, this is your Application's **Domain** prepended with `https://`. This can be set automatically with an `ISSUER_BASE_URL` variable in your environment.

If you are using a response type that includes `code`, you will need an additional configuration property:
Expand Down Expand Up @@ -67,13 +67,15 @@ New values can be passed in to change what is returned from the authorization se
For example, to receive an access token for an API, you could initialize like the sample below. Note that `response_mode` can be omitted because the OAuth2 default mode of `query` is fine:

```js
app.use(auth({
authorizationParams: {
response_type: "code",
scope: "openid profile email read:reports",
audience: "https://your-api-identifier"
}
}));
app.use(
auth({
authorizationParams: {
response_type: 'code',
scope: 'openid profile email read:reports',
audience: 'https://your-api-identifier',
},
})
);
```

Additional custom parameters can be added as well:
Expand All @@ -99,8 +101,8 @@ The `requiresAuth()` function is an optional middleware that protects specific a

```js
const { auth, requiresAuth } = require('express-openid-connect');
app.use( auth( { authRequired: false } ) );
app.use( '/admin', requiresAuth(), (req, res) => res.render('admin') );
app.use(auth({ authRequired: false }));
app.use('/admin', requiresAuth(), (req, res) => res.render('admin'));
```

Using `requiresAuth()` on its own without initializing `auth()` will throw a `401 Unauthorized` error instead of triggering the login process:
Expand Down
Loading