Login (v1.1)

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

Table of contents

mod-login API

This module provides a username/password based login mechanism for FOLIO credentials

/authn

GET /authn/loginAttempts/{id}

Get login attempts for a single user

GET /authn/loginAttempts/{id}
URI Parameters
  • id: required (string)

Response 200

Body

Media type: application/json

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 /authn/login

Get a new login token

POST /authn/login
Body

Media type: application/json

Type: json

Content:

{
  "title": "Login Credentials Schema",
  "type": "object",
  "description": "An entity that describes the basic credentials for a user to log on to the system",
  "properties": {
    "username": {
      "description": "Username in the system",
      "type": "string"
    },
    "userId": {
      "description": "Unique user id",
      "type": "string"
    },
    "password": {
      "description": "User password",
      "type": "string"
    }
  }
}

Response 201

Headers
  • x-okapi-token: required (string)
  • refreshtoken: required (string)
Body

Media type: application/json

Type: json

Content:

{
  "title": "Login Credentials Schema",
  "type": "object",
  "description": "An entity that describes the basic credentials for a user to log on to the system",
  "properties": {
    "username": {
      "description": "Username in the system",
      "type": "string"
    },
    "userId": {
      "description": "Unique user id",
      "type": "string"
    },
    "password": {
      "description": "User password",
      "type": "string"
    }
  }
}

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 422

Unprocessable Entity

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"
    }
  }
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /authn/update

Self-update existing credentials

POST /authn/update
Body

Media type: application/json

Type: json

Content:

{
  "title": "Update Credentials Schema",
  "type": "object",
  "description": "An entity that describes the necessary data to update a user password",
  "properties": {
    "username": {
      "description": "username",
      "type": "string"
    },
    "userId": {
      "description": "Unique user id",
      "type": "string"
    },
    "password": {
      "description": "The current password of the user who will be replaced by the new one",
      "type": "string"
    },
    "newPassword" : {
      "description": "New user password",
      "type": "string"
    }
  }
}

Response 204

Successful update

Response 400

Bad request

Body

Media type: text/plain

Type: any

Example:

Bad request

Response 401

Unauthorized

Body

Media type: text/plain

Type: any

Example:

Unauthorized

Response 422

Unprocessable Entity

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"
    }
  }
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /authn/credentials

Get a list of user credentials

GET /authn/credentials
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.

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Credentials List Object",
  "type": "object",
  "description": "Response entity describing a list of user data, as well as their number in db",
  "properties": {
    "credentials": {
      "type": "array",
      "description": "List of user credentials",
      "id": "credentialsListObject",
      "items": {
        "type": "object",
        "$ref": "credentials.json"
      }
    },
    "totalRecords": {
      "type": "integer"
    }
  },
  "required": [
    "credentials",
    "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 /authn/credentials

Add a new login to the system

POST /authn/credentials
Body

Media type: application/json

Type: json

Content:

{
  "title": "Login Credentials Schema",
  "type": "object",
  "description": "An entity that describes the basic credentials for a user to log on to the system",
  "properties": {
    "username": {
      "description": "Username in the system",
      "type": "string"
    },
    "userId": {
      "description": "Unique user id",
      "type": "string"
    },
    "password": {
      "description": "User password",
      "type": "string"
    }
  }
}

Response 201

Body

Media type: application/json

Type: json

Content:

{
  "title": "Credentials Schema",
  "type": "object",
  "description": "An entity that describes the basic user login data",
  "properties": {
    "id": {
      "description": "Unique credentials id",
      "type": "string"
    },
    "userId": {
      "description": "Unique user id",
      "type": "string"
    },
    "hash": {
      "description": "The generated hash that participates in decoding the password",
      "type": "string"
    },
    "salt": {
      "description": "The generated salt that is involved in decrypting the password",
      "type": "string"
    },
    "metadata": {
      "type": "object",
      "$ref": "raml-util/schemas/metadata.schema"
    }
  }
}

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 /authn/credentials/{id}

Get login credentials for a single user

GET /authn/credentials/{id}
URI Parameters
  • id: required (string)

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "title": "Credentials Schema",
  "type": "object",
  "description": "An entity that describes the basic user login data",
  "properties": {
    "id": {
      "description": "Unique credentials id",
      "type": "string"
    },
    "userId": {
      "description": "Unique user id",
      "type": "string"
    },
    "hash": {
      "description": "The generated hash that participates in decoding the password",
      "type": "string"
    },
    "salt": {
      "description": "The generated salt that is involved in decrypting the password",
      "type": "string"
    },
    "metadata": {
      "type": "object",
      "$ref": "raml-util/schemas/metadata.schema"
    }
  }
}

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

PUT /authn/credentials/{id}

Modify a user's login credentials

PUT /authn/credentials/{id}
URI Parameters
  • id: required (string)
Body

Media type: application/json

Type: json

Content:

{
  "title": "Login Credentials Schema",
  "type": "object",
  "description": "An entity that describes the basic credentials for a user to log on to the system",
  "properties": {
    "username": {
      "description": "Username in the system",
      "type": "string"
    },
    "userId": {
      "description": "Unique user id",
      "type": "string"
    },
    "password": {
      "description": "User password",
      "type": "string"
    }
  }
}

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "title": "Login Credentials Schema",
  "type": "object",
  "description": "An entity that describes the basic credentials for a user to log on to the system",
  "properties": {
    "username": {
      "description": "Username in the system",
      "type": "string"
    },
    "userId": {
      "description": "Unique user id",
      "type": "string"
    },
    "password": {
      "description": "User password",
      "type": "string"
    }
  }
}

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

DELETE /authn/credentials/{id}

Remove a user's login credentials from the system

DELETE /authn/credentials/{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

POST /authn/password/repeatable

Validate password for repeatability

POST /authn/password/repeatable
Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Object with password property",
  "type": "object",
  "properties": {
    "password": {
      "type": "string",
      "description": "Password"
    }
  },
  "required": [
    "password"
  ]
}

Response 200

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "result",
  "type": "object",
  "properties": {
    "result": {
      "type": "string",
      "description": "result"
    }
  },
  "required": [
    "result"
  ]
}

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /authn/reset-password

Resets password for user in record and deletes action record

POST /authn/reset-password
Body

Media type: application/json

Response 201

Body

Media type: application/json

Response 400

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 /authn/password-reset-action

Saves action to storage

POST /authn/password-reset-action
Body

Media type: application/json

Response 201

Body

Media type: application/json

Response 400

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

GET /authn/password-reset-action/{actionId}

Retrieves action record by id

GET /authn/password-reset-action/{actionId}
URI Parameters
  • actionId: required (string)

Response 200

Body

Media type: application/json

Response 400

Body

Media type: text/plain

Type: any

Example:

Bad Request

Response 404

Body

Media type: text/plain

Type: any

Example:

Not Found

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

GET /authn/log/events

Returns a list of events retrieved from storage

GET /authn/log/events
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).

  • query: (string)

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

Response 200

Body

Media type: application/json

Response 204

Body

Media type: text/plain

Type: any

Example:

No Content

Response 404

Event not found

Body

Media type: text/plain

Type: any

Example:

Event not found

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

POST /authn/log/events

Saves received event into the storage

POST /authn/log/events
Body

Media type: application/json

Response 201

Body

Media type: application/json

Response 204

Body

Media type: text/plain

Type: any

Example:

No Content

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error

DELETE /authn/log/events/{id}

Removes events by filter

DELETE /authn/log/events/{id}
URI Parameters
  • id: required (string)

Response 200

Body

Media type: application/json

Response 204

Body

Media type: text/plain

Type: any

Example:

No Content

Response 404

Event not found

Body

Media type: text/plain

Type: any

Example:

Event not found

Response 500

Internal server error

Body

Media type: text/plain

Type: any

Example:

Internal server error