ory-keto-client
Version:
Ory Keto access control client for JavaScript and TypeScript
102 lines (61 loc) • 2.54 kB
Markdown
[](https://www.npmjs.com/package/ory-keto-client)
[](https://www.npmjs.com/package/ory-keto-client)
[](https://www.npmjs.com/package/ory-keto-client)
[](https://github.com/codejamninja/ory-keto-client)
> Ory Keto access control client for JavaScript and TypeScript
Please ★ this repo if you found it useful ★ ★ ★
* compatible with typescript
* supports multiple roles
* supports custom policies
```sh
npm install --save ory-keto-client
```
* [NodeJS](https://nodejs.org)
Import `ory-keto-client`
```js
import Keto from 'ory-keto-client';
```
Create keto instance
```js
const { env } = process;
const keto = new Keto(env.KETO_BASE_URL || 'http://localhost:4466');
```
Create policy
```js
keto.createPolicy({
description: 'bob is allowed read the blog',
subjects: ['bob'],
effect: 'allow',
actions: ['read']
resources: ['blog'],
});
```
Authorize subject
```js
if (await keto.authorizeSubject('bob', 'read', 'blog')) {
console.log('Authorized');
} else {
console.log('Not Authorized');
}
```
Submit an [issue](https://github.com/codejamninja/ory-keto-client/issues/new)
Review the [guidelines for contributing](https://github.com/codejamninja/ory-keto-client/blob/master/CONTRIBUTING.md)
[](https://github.com/codejamninja/ory-keto-client/blob/master/LICENSE)
[](https://codejam.ninja) © 2018
Review the [changelog](https://github.com/codejamninja/ory-keto-client/blob/master/CHANGELOG.md)
* [Jam Risser](https://codejam.ninja) - Author
A ridiculous amount of coffee ☕ ☕ ☕ was consumed in the process of building this project.
[](https://liberapay.com/codejamninja/donate) if you'd like to keep me going!
[](https://liberapay.com/codejamninja/donate)
[](https://liberapay.com/codejamninja/donate)