1.6 KiB
PalAuth IAM client for Node JS
This uses the Fetch API, so technically it could work in the browser too. This is not recommended due to the need to handle PalAuth Client Secret tokens for the requests, as well as CORS restrictions.
Supported features
Currently, only the /check
method is supported. This checks if a given user has a given permission, returning a simply boolean answer.
Installation
Because NPM is evil, this package is instead hosted within this GitLab repo.
Installing it isn't too hard! Just follow these simple steps.
In your some directory, create (or modify) a .yarnrc.yml
file:
npmScopes:
paltiverse-public:
npmRegistryServer: "https://gitlab.palk.me/api/v4/packages/npm"
You will now be able to install any @paltiverse-public
packages.
In the package where you want to install the client, run:
yarn add @paltiverse-public/palauth-iam-node
For more details, see the GitLab docs.
Using NPM or PNPM? See the GitLab NPM docs.
Usage
import PalAuthIAMClient from "@paltiverse-public/palauth-iam-node"
const client = new PalAuthIAMClient({
clientID: "abcdef",
clientSecret: "abcdef",
// If not using auth.palk.me:
baseURL: "https://<my-palauth-instance>/iam",
})
const isAllowed = await client.checkPermission({
userId: "abcdef",
permission: "repositories.issues.create",
})
License
GNU GPL 3.0. See LICENSE.md.