
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@wealthbar/authz
Advanced tools
Short for Authorization (which is "can I" as opposed to Authentication which is "who am I").
type authzType = (ctx: authzCtxType) => boolean
An authz function takes a context (see next section) and returns either true if authorization
is granted, or false is not.
type authzCtxType = {
permissions: {
[name: string]: boolean,
},
user?: {
id?: string,
}
};
An authz context contains information about the current authorized user (their id), and the permissions they currently have.
anonanon always returns true, i.e. everyone is authorized, even those without a user id.
anyUseranyUser returns true for any user. i.e. any logged in users are authorized; sessions without a user id are not.
anyOf(permissions: string[]): authzTypeanyOf generates an authz function that will return true for users with any of the permissions
past in the permissions array.
allOf(permissions: string[]): authzTypeallOf generates an authz function that will return true for users with all of the permissions
past in the permissions array.
anyOfAuthz(authzs: authzType[]): authzTypeanyOfAuthz generates an authz function that will return true for users when any of the authz functions
past in the authzs array return true.
allOfAuthz(authzs: authzType[]): authzTypeallOfAuthz generates an authz function that will return true for users when all of the authz functions
past in the authzs array return true.
import {authz} from "@wealthbar/authz"
const hasAandBorC = authz.anyOfAuthz([authz.allOf(["A", "B"]), authz.anyOf(["C"])]);
hasAandBorC requires a user with permissions to both "A" and "B" or permission to "C".
FAQs
helpers for implementing permission checks
We found that @wealthbar/authz demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.