1.0.0-0f32148 • Published 3 years ago

@kraken.js/auth v1.0.0-0f32148

Weekly downloads
159
License
MIT
Repository
github
Last release
3 years ago

@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 }
1.0.0-0f32148

3 years ago

1.0.0-5dccf74

3 years ago

0.0.6-1ce86fe

3 years ago

0.0.6-9e312f7

3 years ago

0.0.6-5a7fedf

3 years ago

0.0.6-b9fc49d

3 years ago

0.0.6-730877f

3 years ago

0.0.6-d282bc5

3 years ago

0.0.6-a032174

3 years ago

0.0.6-7783b12

3 years ago

0.0.6-a0c0d94

3 years ago

0.0.6-23e13b8

3 years ago

0.0.6-8735127

3 years ago

0.0.6-a423145

3 years ago

0.0.6-a8a3d2b

3 years ago

0.0.6-c999dee

3 years ago

0.0.6-f7489f8

3 years ago

0.0.6-db455b2

3 years ago

0.0.6-d89c3e3

3 years ago

0.0.6-88caa7a

3 years ago

0.0.6-dc46f62

3 years ago

0.0.6-fdf33df

3 years ago

0.0.6-d0f4162

3 years ago

0.0.6-b0b1b42

3 years ago

0.0.6-09cbfba

4 years ago

0.0.6-433184c

4 years ago

0.0.6-151db1e

4 years ago

0.0.6-3e948b8

4 years ago

0.0.6-950839d

4 years ago

0.0.6-072e508

4 years ago

0.0.5

4 years ago

0.0.5-189c1e2

4 years ago

0.0.5-50e5466

4 years ago

0.0.5-caee67b

4 years ago

0.0.5-b45b1f6

4 years ago

0.0.5-04a6021

4 years ago

0.0.5-4ff3204

4 years ago

0.0.5-4d631f5

4 years ago

0.0.5-ce7aa33

4 years ago

0.0.5-1e6181d

4 years ago

0.0.5-775b6f6

4 years ago

0.0.5-737c897

4 years ago

0.0.5-fd920ec

4 years ago

0.0.5-6188524

4 years ago

0.0.5-ee5cf97

4 years ago

0.0.5-94468a8

4 years ago

0.0.5-1de543a

4 years ago

0.0.5-c280766

4 years ago

0.0.5-cd55fd9

4 years ago

0.0.5-b01b05b

4 years ago

0.0.5-7fa83cb

4 years ago

0.0.5-59e2826

4 years ago

0.0.5-6a28701

4 years ago

0.0.5-8df7930

4 years ago

0.0.5-8d4580d

4 years ago

0.0.5-823a43f

4 years ago

0.0.5-b3afe68

4 years ago

0.0.5-4ea68a3

4 years ago

0.0.5-2d533e1

4 years ago

0.0.5-629917a

4 years ago

0.0.5-5fa6142

4 years ago

0.0.5-7045233

4 years ago

0.0.5-1e21840

4 years ago

0.0.5-8e51484

4 years ago

0.0.5-6c7f46f

4 years ago

0.0.5-3ad9e2f

4 years ago

0.0.5-117d74b

4 years ago

0.0.5-c378fe1

4 years ago

0.0.5-b248c32

4 years ago

0.0.5-aa2944c

4 years ago

0.0.4

4 years ago

0.0.4-3d82113

4 years ago

0.0.4-7bad9b9

4 years ago

0.0.4-228255d

4 years ago

0.0.4-5ed4dbe

4 years ago

0.0.4-b174638

4 years ago

0.0.4-351f689

4 years ago