Jupyter Notebook Authorization API

Token verification and authorization checks.

OpenAPI Specification

jupyter-notebook-authorization-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Jupyter Notebook Jupyter Kernel Gateway Authorization API
  description: 'REST API for the Jupyter Kernel Gateway, a web server that provides headless access to Jupyter kernels. The Kernel Gateway supports two modes: jupyter-websocket mode (default) which provides a Jupyter Notebook server-compatible API for kernel management, and notebook-http mode which maps notebook cells to HTTP endpoints. This spec covers the jupyter-websocket mode API.'
  version: 3.0.0
  license:
    name: BSD-3-Clause
    url: https://opensource.org/licenses/BSD-3-Clause
  contact:
    name: Jupyter Project
    url: https://jupyter-kernel-gateway.readthedocs.io
    email: jupyter@googlegroups.com
servers:
- url: http://localhost:8888/api
  description: Local Jupyter Kernel Gateway server
security:
- token: []
- tokenQuery: []
tags:
- name: Authorization
  description: Token verification and authorization checks.
paths:
  /authorizations/token/{token}:
    get:
      operationId: checkToken
      summary: Jupyter Notebook Identify a user by token
      description: Identify the user associated with a given API token. Used by services to verify token authentication.
      tags:
      - Authorization
      parameters:
      - name: token
        in: path
        required: true
        description: The API token to check.
        schema:
          type: string
      responses:
        '200':
          description: Token is valid, returns user information.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '404':
          description: Token not found or invalid.
components:
  schemas:
    User:
      type: object
      description: A JupyterHub user.
      properties:
        name:
          type: string
          description: The username.
        admin:
          type: boolean
          description: Whether the user is an admin.
        roles:
          type: array
          description: Roles assigned to the user.
          items:
            type: string
        groups:
          type: array
          description: Groups the user belongs to.
          items:
            type: string
        server:
          type:
          - string
          - 'null'
          description: URL path of the user's default server, or null if not running.
        pending:
          type:
          - string
          - 'null'
          description: Pending action for the server, such as 'spawn' or 'stop', or null if no pending action.
          enum:
          - spawn
          - stop
          - null
        last_activity:
          type:
          - string
          - 'null'
          format: date-time
          description: Timestamp of last activity.
        created:
          type: string
          format: date-time
          description: Timestamp when the user was created.
        servers:
          type: object
          description: Map of named servers to their details.
          additionalProperties:
            $ref: '#/components/schemas/Server'
        scopes:
          type: array
          description: OAuth scopes for the user.
          items:
            type: string
        auth_state:
          description: Authentication state (only included when requested, admin only).
      required:
      - name
      - admin
    Server:
      type: object
      description: A user's single-user notebook server.
      properties:
        name:
          type: string
          description: Name of the server (empty string for default).
        ready:
          type: boolean
          description: Whether the server is ready to accept connections.
        pending:
          type:
          - string
          - 'null'
          description: Pending action for the server.
        url:
          type: string
          description: URL path of the running server.
        progress_url:
          type: string
          description: URL for the server's spawn progress events.
        started:
          type: string
          format: date-time
          description: Timestamp when the server was started.
        last_activity:
          type: string
          format: date-time
          description: Timestamp of last activity on the server.
        state:
          type: object
          description: Spawner state (admin only).
          additionalProperties: true
        user_options:
          type: object
          description: User options passed at spawn time.
          additionalProperties: true
  securitySchemes:
    token:
      type: apiKey
      in: header
      name: Authorization
      description: Authentication token configured via KG_AUTH_TOKEN. Passed as 'token <token_value>' in the Authorization header.
    tokenQuery:
      type: apiKey
      in: query
      name: token
      description: Authentication token passed as a query parameter.