Socket
Book a DemoInstallSign in
Socket

@kraken.js/auth

Package Overview
Dependencies
Maintainers
2
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@kraken.js/auth

## Definition

0.0.5-4d631f5
unpublished
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

@auth

Definition

directive @auth(rules: [AuthRule], silent: Boolean = true) on OBJECT | FIELD_DEFINITION

input AuthRule {
  # source of value
  args: String
  source: String
  authorizer: String
  # rules
  match: [String]
  truthy: Boolean
}

Usage Samples

Some usage samples

Authorizer must have property roles matching any

type SecureObject @auth(rules: [{ authorizer: "roles",  match: ["secure.read"] }]) { secureField: String }

Authorizer must be the owner of the object

type SecureObject @auth(rules: [{ authorizer: "sub",  source: "owner" }]) { secureField: String }

Authorizer groups allowed in the source object

type SecureObject @auth(rules: [{ authorizer: "groups",  source: "editors" }]) { secureField: String, editors: [String] }

Source object marked as public

type SecureObject @auth(rules: [{ source: "isPublic", truthy: true }]) { secureField: String, isPublic: Boolean }

User is creating an object setting as the owner (match with args)

Single value

type SecureObject { owner: String }
input CreateSecureObject { owner: String }

type Mutation { createSecureObject(input: CreateSecureObject): SecureObject @auth(rules: [
  { authorizer: "sub", args: "input.owner" }
])}

Multiple values

type SecureObject { owners: [String] }
input CreateSecureObject { owners: [String] }

type Mutation { createSecureObject(input: CreateSecureObject): SecureObject @auth(rules: [
  { authorizer: "sub", args: "input.owners" }
])}

Multiple rules

When configuring multiple rules if any of them evaluates as true the operation will authorize

type SecureObject @auth(rules: [
  { authorizer: "roles",  match: ["secure.read"] },
  { source: "isPublic",  truthy: true },
  { authorizer: "sub",  source: "owner" },
  { authorizer: "sub",  source: "readers" },
  { authorizer: "groups",  source: "readers" }
]) { secureField: String }

FAQs

Package last updated on 27 Oct 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.