Permissions (v1)

http://github.com/org/folio/mod-auth/permissions

Table of contents

mod-permissions API

This module is responsible for managing and retrieving permissions in the FOLIO system

/perms

GET /perms/users

Get a list of users

GET /perms/users
Query Parameters
  • length: (integer - default: 10 - minimum: 1 - maximum: 1000)

    The maximum number of results to return.

    Example:

    10
  • start: (integer - default: 1 - minimum: 1 - maximum: 1000)

    The starting index in a list of results (starts at one).

  • sortBy: (string)

    A comma-separated list of fieldnames to sort by

  • query: (string)

    A query string to filter users based on matching criteria in fields.

  • hasPermissions: (string)

    A list of permissions that any returned users must possess.

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "permissionUsers": {
      "type": "array",
      "id": "permissionUsersListObject",
      "items": {
        "type": "object",
        "$ref": "permissionUser.json"
      }
    },
    "totalRecords": {
      "type": "integer"
    }
  },
  "required": [
    "permissionUsers",
    "totalRecords"
  ]
}

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 403

Access Denied

Body

Media type: text/plain

Type: any

Example:

Access Denied

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /perms/users

Add a new user

POST /perms/users
Body

Media type: application/json

Type: json

Content:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "userId": {
      "type": "string"
    },
    "permissions": {
      "type": "array"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties": false
}

Response 201

Body

Media type: application/json

Type: json

Content:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "userId": {
      "type": "string"
    },
    "permissions": {
      "type": "array"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties": false
}

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /perms/users/{id}

Get a permission user

GET /perms/users/{id}
URI Parameters
  • id: required (string)
Query Parameters
  • indexField: (string)

    Specify a field other than 'id' to look up the permission user by

    Example:

    userId

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "userId": {
      "type": "string"
    },
    "permissions": {
      "type": "array"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties": false
}

Response 403

Access Denied

Body

Media type: text/plain

Type: any

Example:

Access Denied

Response 404

User not found

Body

Media type: text/plain

Type: any

Example:

User does not exist

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

PUT /perms/users/{id}

Modify an existing user

PUT /perms/users/{id}
URI Parameters
  • id: required (string)
Body

Media type: application/json

Type: json

Content:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "userId": {
      "type": "string"
    },
    "permissions": {
      "type": "array"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties": false
}

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "userId": {
      "type": "string"
    },
    "permissions": {
      "type": "array"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties": false
}

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 404

User not found

Body

Media type: text/plain

Type: any

Example:

User not found

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

DELETE /perms/users/{id}

Remove a user

DELETE /perms/users/{id}
URI Parameters
  • id: required (string)

Response 204

Body

Media type: text/plain

Type: any

Response 404

User not found

Body

Media type: text/plain

Type: any

Example:

User not found

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /perms/users/{id}/permissions

Get permissions that a user has

GET /perms/users/{id}/permissions
URI Parameters
  • id: required (string)
Query Parameters
  • expanded: (string)

    Recursively return all subpermissions

    Example:

    true
  • full: (string)

    Return full permission objects, as opposed to just permission names

    Example:

    true
  • indexField: (string)

    Specify a field other than 'id' to look up the permission user by

    Example:

    userId

Response 200

An object of returned permissions

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "permissionNames": {
      "type": "array",
      "id": "permissionNameListObject"
    },
    "totalRecords": {
      "type": "integer"
    }
  },
  "required": [
    "permissionNames",
    "totalRecords"
  ]
}

Response 403

Access Denied

Body

Media type: text/plain

Type: any

Example:

Access Denied

Response 404

User not found

Body

Media type: text/plain

Type: any

Example:

User not found

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /perms/users/{id}/permissions

Add a permission to a user

POST /perms/users/{id}/permissions
URI Parameters
  • id: required (string)
Query Parameters
  • indexField: (string)

    Specify a field other than 'id' to look up the permission user by

    Example:

    userId
Body

Media type: application/json

Type: json

Content:

{
  "title": "Permissions Name Schema",
  "type": "object",
  "properties": {
    "permissionName": {
      "type": "string"
    }
  }
}

Response 200

The added permission

Body

Media type: application/json

Type: json

Content:

{
  "title": "Permissions Name Schema",
  "type": "object",
  "properties": {
    "permissionName": {
      "type": "string"
    }
  }
}

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

DELETE /perms/users/{id}/permissions/{permissionname}

Remove a permission from a user

DELETE /perms/users/{id}/permissions/{permissionname}
URI Parameters
  • id: required (string)
  • permissionname: required (string)
Query Parameters
  • indexField: (string)

    Specify a field other than 'id' to look up the permission user by

    Example:

    userId

Response 204

Body

Media type: text/plain

Type: any

Response 400

Bad request

Body

Media type: text/plain

Type: any

Response 404

Permission not found in user

Body

Media type: text/plain

Type: any

Example:

Permission not found in user

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /perms/permissions

Get a list of existing permissions

GET /perms/permissions
Query Parameters
  • expandSubs: (string)

    Return subpermissions as objects

    Example:

    true
  • includeDummy: (string)

    Return placeholder 'dummy' permissions

    Example:

    true
  • length: (integer - default: 10 - minimum: 1 - maximum: 1000)

    The maximum number of results to return.

    Example:

    10
  • start: (integer - default: 1 - minimum: 1 - maximum: 1000)

    The starting index in a list of results (starts at one).

  • sortBy: (string)

    A comma-separated list of fieldnames to sort by

  • query: (string)

    A query string to filter users based on matching criteria in fields.

  • memberOf: (string)

    A list of permission names that any returned permission must be a sub-permission of.

  • ownedBy: (string)

    A list of user names that any returned permissions must belong to.

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "permissions": {
      "type": "array",
      "id": "permissionsListObject",
      "items": {
        "type": "object",
        "$ref": "permission.json"
      }
    },
    "totalRecords": {
      "type": "integer"
    }
  },
  "required": [
    "permissions",
    "totalRecords"
  ]
}

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /perms/permissions

Add a new permission

POST /perms/permissions
Body

Media type: application/json

Type: json

Content:

{
  "title": "Permissions Definition Schema",
  "type": "object",
  "properties": {
    "permissionName": {
      "type": "string"
    },
    "displayName": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "subPermissions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "mutable": {
      "type": "boolean"
    },
    "visible": {
      "type": "boolean"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties": false
}

Response 201

Body

Media type: application/json

Type: json

Content:

{
  "title": "Permissions Definition Schema",
  "type": "object",
  "properties": {
    "permissionName": {
      "type": "string"
    },
    "displayName": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "subPermissions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "mutable": {
      "type": "boolean"
    },
    "visible": {
      "type": "boolean"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties": false
}

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /perms/permissions/{id}

Get an existing permission by id

GET /perms/permissions/{id}
URI Parameters
  • id: required (string)

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "title": "Permissions Definition Schema",
  "type": "object",
  "properties": {
    "permissionName": {
      "type": "string"
    },
    "displayName": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "subPermissions": {
      "type": "array"
    },
    "childOf": {
      "type": "array"
    },
    "grantedTo": {
      "type": "array"
    },
    "mutable": {
      "type": "boolean"
    },
    "visible" : {
      "type" : "boolean"
    },
    "dummy" : {
      "type" : "boolean"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties" : false
}

Response 404

Permission not found

Body

Media type: text/plain

Type: any

Example:

Permission not found

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

PUT /perms/permissions/{id}

Modify an existing permission

PUT /perms/permissions/{id}
URI Parameters
  • id: required (string)
Body

Media type: application/json

Type: json

Content:

{
  "title": "Permissions Definition Schema",
  "type": "object",
  "properties": {
    "permissionName": {
      "type": "string"
    },
    "displayName": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "subPermissions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "mutable": {
      "type": "boolean"
    },
    "visible": {
      "type": "boolean"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties": false
}

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "title": "Permissions Definition Schema",
  "type": "object",
  "properties": {
    "permissionName": {
      "type": "string"
    },
    "displayName": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "subPermissions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "mutable": {
      "type": "boolean"
    },
    "visible": {
      "type": "boolean"
    },
    "metadata" : {
      "type" : "object",
      "$ref" : "../metadata.schema"
    }
  },
  "additionalProperties": false
}

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 404

Permission not found

Body

Media type: text/plain

Type: any

Example:

Permission not found

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

DELETE /perms/permissions/{id}

Remove a permission

DELETE /perms/permissions/{id}
URI Parameters
  • id: required (string)

Response 204

Body

Media type: text/plain

Type: any

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 404

Permission not found

Body

Media type: text/plain

Type: any

Example:

Permission not found

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error