Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CSRFHandler

This handler adds a CSRF token to requests which mutate state. In order change the state a (XSRF-TOKEN) cookie is set with a unique token, that is expected to be sent back in a (X-XSRF-TOKEN) header.

The behavior is to check the request body header and cookie for validity.

This Handler requires session support, thus should be added somewhere below Session and Body handlers.

Hierarchy

  • CSRFHandler

Implements

Index

Properties

Static Readonly DEFAULT_COOKIE_NAME

DEFAULT_COOKIE_NAME: string

Static Readonly DEFAULT_COOKIE_PATH

DEFAULT_COOKIE_PATH: string

Static Readonly DEFAULT_HEADER_NAME

DEFAULT_HEADER_NAME: string

Methods

handle

setCookieHttpOnly

setCookieName

  • Set the cookie name. By default XSRF-TOKEN is used as it is the expected name by AngularJS however other frameworks might use other names.

    Parameters

    • name: string

    Returns CSRFHandler

setCookiePath

  • Set the cookie path. By default / is used.

    Parameters

    • path: string

    Returns CSRFHandler

setCookieSecure

  • Sets the cookie secure flag. When set this flag instructs browsers to only send the cookie over HTTPS.

    Parameters

    • secure: boolean

    Returns CSRFHandler

setHeaderName

  • Set the header name. By default X-XSRF-TOKEN is used as it is the expected name by AngularJS however other frameworks might use other names.

    Parameters

    • name: string

    Returns CSRFHandler

setNagHttps

  • Should the handler give warning messages if this handler is used in other than https protocols?

    Parameters

    • nag: boolean

    Returns CSRFHandler

setOrigin

  • Set the origin for this server. When this value is set, extra validation will occur. The request must match the origin server, port and protocol.

    Parameters

    • origin: string

    Returns CSRFHandler

setTimeout

  • Set the timeout for tokens generated by the handler, by default it uses the default from the session handler.

    Parameters

    • timeout: number

    Returns CSRFHandler

Static create

  • Instantiate a new CSRFHandlerImpl with a secret

    CSRFHandler.create("s3cr37")
    

    Parameters

    • vertx: Vertx
    • secret: string

    Returns CSRFHandler

Generated using TypeDoc