feat: more flexible composited authenication#195
Merged
mcollina merged 1 commit intofastify:masterfrom Apr 20, 2023
shenxdtw:master
Merged
feat: more flexible composited authenication#195mcollina merged 1 commit intofastify:masterfrom shenxdtw:master
mcollina merged 1 commit intofastify:masterfrom
shenxdtw:master
Conversation
Member
|
Bruh, just update the same PR/branch, no need to keep creating and deleting PRs. :) |
Eomm
reviewed
Apr 20, 2023
| /* eslint-disable-next-line no-var */ | ||
| for (var i = 0; i < functions.length; i++) { | ||
| functions[i] = functions[i].bind(this) | ||
| if (functions[i] instanceof Array) { |
Member
There was a problem hiding this comment.
Suggested change
| if (functions[i] instanceof Array) { | |
| if (Array.isArray(functions[i])) { |
| functions[i][j] = functions[i][j].bind(this) | ||
| } | ||
| } else { | ||
| functions[i] = [functions[i].bind(this)] |
Member
There was a problem hiding this comment.
I would invert the if/else case
First the most common and with less code
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
According to the current version, only a default relationship of either all
ANDor allORcan be set.If I want to configure the following verification relationship:
[(verifyUserPassword
andverifyLevel)or(verifyVIP)]it cannot be configured.
This PR is intended to address more complex authorization scenarios in practice, including both AND and OR relationships.
I will treat it as a two-dimensional array where each element represents a verification method, and the second dimension of the array always has an
ANDrelationship.And it is backwards compatible with defaultRelation OR and AND.
Checklist
npm run testandnpm run benchmarkand the Code of conduct