Permissions

class AllowAny[source]

Allow any permission class

async has_permission(scope, consumer, action, **kwargs)[source]

Called on every websocket message sent before the corresponding action handler is called.

Parameters:
  • scope (Dict[str, Any]) –

  • consumer (AsyncConsumer) –

  • action (str) –

Return type:

bool

class BasePermission[source]

Base permission class

Notes

You should extend this class and override the has_permission method to create your own permission class.

async has_permission (scope, consumer, action, **kwargs)
async can_connect(scope, consumer, message=None)[source]

Called during connection to validate if a given client can establish a websocket connection.

By default, this returns True and permits all connections to be made.

Parameters:
  • scope (Dict[str, Any]) –

  • consumer (AsyncConsumer) –

Return type:

bool

async has_permission(scope, consumer, action, **kwargs)[source]

Called on every websocket message sent before the corresponding action handler is called.

Parameters:
  • scope (Dict[str, Any]) –

  • consumer (AsyncConsumer) –

  • action (str) –

Return type:

bool

class IsAuthenticated[source]

Allow authenticated users

async has_permission(scope, consumer, action, **kwargs)[source]

Called on every websocket message sent before the corresponding action handler is called.

Parameters:
  • scope (Dict[str, Any]) –

  • consumer (AsyncConsumer) –

  • action (str) –

Return type:

bool

class WrappedDRFPermission(permission)[source]

Used to wrap an instance of DRF permissions class.

Parameters:

permission (BasePermission) –

async can_connect(scope, consumer, message=None)[source]

Called during connection to validate if a given client can establish a websocket connection.

By default, this returns True and permits all connections to be made.

Parameters:
  • scope (Dict[str, Any]) –

  • consumer (AsyncConsumer) –

Return type:

bool

async has_permission(scope, consumer, action, **kwargs)[source]

Called on every websocket message sent before the corresponding action handler is called.

Parameters:
  • scope (Dict[str, Any]) –

  • consumer (AsyncConsumer) –

  • action (str) –

Return type:

bool