Skip to main content

Access

Access configuration allows Inigo's users to apply fine-grained authorization and access controls. Not all clients are the same; you may have authenticated and unauthenticated clients using your application. Using the access control capabilities of Inigo, you can enforce strong authorization controls depending on the context of your clients.


Sample Config

access.yaml

kind: Access
name: demo
label: starwars
spec:
roles:
- name: viewer
config_files:
- access/viewer.inigo
allowed_operations:
- access/viewer.graphql
- name: director
config_files:
- access/director.inigo
- name: actor
config_files:
- access/actor.inigo
- name: producer
config_files:
- access/producer.inigo

profiles:
- name: guest
introspection_mode: partial
- name: user
introspection_mode: full
- name: admin
introspection_mode: full

viewer.inigo

query {
login
logout

films {
director
title
characters {
name
appearedIn
}
}
people
}

type Film {
title
director
characters
}

type Person {
name
birthYear
height
ssn
}

viewer.graphql

query Planets {
planets {
name
appearedIn {
title
}
}
}

actor.inigo

query {
login
logout
version {
version
date
commit
}
}

mutation {
userAdd
userRemove
}

director.inigo

query {
login
logout

films {
title
director
episodeId
openingCrawl
producer
characters {
name
height
}
planets {
name
climate
}
species {
name
skinColor
}
starships {
name
crew
}
vehicles {
name
model
}
}

people {
name
}
}

producer.inigo

query {
login
logout

films {
title
director
episodeId
openingCrawl
producer
characters {
name
height
}
planets {
name
climate
}
species {
name
skinColor
}
starships {
name
crew
}
vehicles {
name
model
}
}

people {
name
}
}

@access Directive

Inigo also provides the ability to configure access directly in graphql schema via @access directive.

Let's take a look at the access directive usage in this simple example:

scalar Int
scalar String

schema {
query : Query
}

type Query {
user: User @access(role: ["user", "admin"])
}

type User {
id: Int!
fullname: String
email: String! @access(role: ["admin"])
}

directive
@access(
role: [String] = ["allowed role"]
) on FIELD_DEFINITION

Such schema will create access configuration for user role that will look like this:

query {
user: User
}

type User {
id
fullname
}

and for the admin role:

query {
user: User
}

type User {
id
fullname
email
}

Note that User.email field is only accesible for admin role, according to the directive configuration.

If the field has non-primitive type, the acces directvie will grant access to all of the nested fieds and types, excluding those that have another access direcive without given role.


You can also combine access configuration files with access directive.

Spec

This section defines the format of Inigo's Access type configuration files. Fields marked as required must be specified if the parent is defined.

FieldTypeDescription
access_modestring default:blockOne of:
- block
- partial
operation_registryOperationRegistry
schema_directive_path_scopestring default:"@access.role"Path to access scope on schema. Example: @auth.scope. Directive argument 'scope' must be of type [String] or compatible.
schema_directive_path_statestringPath to access state on schema. Example: @auth.state. Directive argument 'state' must be of type [Enum] or compatible.
profile_default_valuesAccessProfileDefaultValues
profiles[AccessProfile]
role_default_valuesAccessRoleDefaultValues
roles[AccessRole]

OperationRegistry

FieldTypeDescription
enabledboolean
operation_id_pathstring
security_modestring default:auditOperation registry security mode. You can specify the registry behaviour based on provided operation id / query string.
One of:
- allow_operation_id: allow using persisted operation id. it is optional, regular requests are also working.
- audit: operation id is optional but unregistered queries are being logged as warnings
- safelist: only persisted queries are allowed, by operation id or by query string
- operation_id_only: persisted operation id is mandatory, query strings are considered unrecognized
operations_files[string]Relative path to the filesystem location of your operations graphql files.

For example: access_files/operations.graphql
operations_map_files[string]Relative path to the filesystem location of your operations json map files.

For example: access_files/operations.json

AccessProfileDefaultValues

FieldTypeDescription
introspection_modestring default:noneIntrospection mode policy for the given profile.

One of:
- none
- full
- partial
- block

AccessProfile

FieldTypeDescription
Namestring requiredName of the profile.
introspection_modestring default:noneIntrospection mode policy for the given profile.

One of:
- none
- full
- partial
- block

AccessRoleDefaultValues

FieldTypeDescription
full_accessbooleanGrants full schema access to the role. This setting takes presedence and over any access configuration files.
allowed_operations[string]Relative path to the filesystem location of your files containing allowed operations.

For example: allowed_operations/viewer.graphql
config_files[string]Relative path to the filesystem location of your access files.

For example: access_files/viewer.inigo.
operation_files[string]

AccessRole

FieldTypeDescription
Namestring requiredName of the role.
full_accessbooleanGrants full schema access to the role. This setting takes presedence and over any access configuration files.
allowed_operations[string]Relative path to the filesystem location of your files containing allowed operations.

For example: allowed_operations/viewer.graphql
config_files[string]Relative path to the filesystem location of your access files.

For example: access_files/viewer.inigo.
operation_files[string]