AuthorizeModule Class

.NET Framework 4

Applies authorization attributes from the Hub class to determine whether to allow clients to receive messages sent from the hub.

Inheritance Hierarchy

System.Object
  Microsoft.AspNet.SignalR.Hubs.HubPipelineModule
    Microsoft.AspNet.SignalR.Hubs.AuthorizeModule

Namespace:  Microsoft.AspNet.SignalR.Hubs
Assembly:  Microsoft.AspNet.SignalR.Core (in Microsoft.AspNet.SignalR.Core.dll)

Syntax

'Declaration
Public Class AuthorizeModule _
    Inherits HubPipelineModule
'Usage
Dim instance As AuthorizeModule
public class AuthorizeModule : HubPipelineModule
public ref class AuthorizeModule : public HubPipelineModule
type AuthorizeModule =  
    class 
        inherit HubPipelineModule 
    end
public class AuthorizeModule extends HubPipelineModule

The AuthorizeModule type exposes the following members.

Constructors

  Name Description
Public method AuthorizeModule()
Public method AuthorizeModule(IAuthorizeHubConnection, IAuthorizeHubMethodInvocation)

Top

Methods

  Name Description
Public method BuildAuthorizeConnect Wraps a function to be called before a client subscribes to signals belonging to the hub described by the HubDescriptor. By default, the AuthorizeModule will look for attributes on the hub to help determine if the client is authorized to subscribe to method invocations for the described hub. The function returns true if the client is authorized to subscribe to client-side hub method invocations; false, otherwise. (Overrides HubPipelineModule.BuildAuthorizeConnect(Func<HubDescriptor, IRequest, Boolean>).)
Public method BuildConnect Wraps a function that is called when a client connects to the HubDispatcher for each IHub the client connects to. By default, this results in the IHub 's OnConnected method being invoked. (Inherited from HubPipelineModule.)
Public method BuildDisconnect Wraps a function that is called when a client disconnects from the HubDispatcher for each IHub the client was connected to. By default, this results in the IHub 's OnDisconnected method being invoked. (Inherited from HubPipelineModule.)
Public method BuildIncoming Wraps a function that invokes a server-side hub method. Even if a client has not been authorized to connect to a hub, it will still be authorized to invoke server-side methods on that hub unless it is prevented in BuildIncoming(Func<IHubIncomingInvokerContext, Task<Object>>) by not executing the invoke parameter. (Overrides HubPipelineModule.BuildIncoming(Func<IHubIncomingInvokerContext, Task<Object>>).)
Public method BuildOutgoing Wraps a function that invokes a client-side hub method. (Inherited from HubPipelineModule.)
Public method BuildReconnect Wraps a function that is called when a client reconnects to the HubDispatcher for each IHub the client connects to. By default, this results in the IHub 's OnReconnected method being invoked. (Inherited from HubPipelineModule.)
Public method BuildRejoiningGroups Wraps a function that determines which of the groups belonging to the hub described by the HubDescriptor the client should be allowed to rejoin. By default, clients that are reconnecting to the server will be removed from all groups they may have previously been a member of, because untrusted clients may claim to be a member of groups they were never authorized to join. (Inherited from HubPipelineModule.)
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Protected method OnAfterConnect This method is called after the connect components of any modules added later to the IHubPipeline are executed and after OnConnected() is executed, if at all. (Inherited from HubPipelineModule.)
Protected method OnAfterDisconnect This method is called after the disconnect components of any modules added later to the IHubPipeline are executed and after OnDisconnected() is executed, if at all. (Inherited from HubPipelineModule.)
Protected method OnAfterIncoming This method is called after the incoming components of any modules added later to the IHubPipeline and the server-side hub method have completed execution. (Inherited from HubPipelineModule.)
Protected method OnAfterOutgoing This method is called after the outgoing components of any modules added later to the IHubPipeline are executed. This does not mean that all the clients have received the hub method invocation, but it does indicate a hub invocation message has successfully been published to a message bus. (Inherited from HubPipelineModule.)
Protected method OnAfterReconnect This method is called after the reconnect components of any modules added later to the IHubPipeline are executed and after OnReconnected() is executed, if at all. (Inherited from HubPipelineModule.)
Protected method OnBeforeAuthorizeConnect This method is called before the AuthorizeConnect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules will not run and the client will not be allowed to subscribe to client-side invocations of methods belonging to the hub defined by the HubDescriptor . (Inherited from HubPipelineModule.)
Protected method OnBeforeConnect This method is called before the connect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the OnConnected() method will not be run. (Inherited from HubPipelineModule.)
Protected method OnBeforeDisconnect This method is called before the disconnect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the OnDisconnected() method will not be run. (Inherited from HubPipelineModule.)
Protected method OnBeforeIncoming This method is called before the incoming components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the server-side hub method invocation will not be executed. Even if a client has not been authorized to connect to a hub, it will still be authorized to invoke server-side methods on that hub unless it is prevented in BuildIncoming(Func<IHubIncomingInvokerContext, Task<Object>>) by not executing the invoke parameter or prevented in OnBeforeIncoming(IHubIncomingInvokerContext) by returning false. (Inherited from HubPipelineModule.)
Protected method OnBeforeOutgoing This method is called before the outgoing components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the client-side hub method invocation(s) will not be executed. (Inherited from HubPipelineModule.)
Protected method OnBeforeReconnect This method is called before the reconnect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the OnReconnected() method will not be run. (Inherited from HubPipelineModule.)
Protected method OnIncomingError This is called when an uncaught exception is thrown by a server-side hub method or the incoming component of a module added later to the IHubPipeline . Observing the exception using this method will not prevent it from bubbling up to other modules. (Inherited from HubPipelineModule.)
Public method ToString (Inherited from Object.)

Top

Remarks

An AuthorizeModule instance is added to the IHubPipeline by default. Hub level attributes that implement IAuthorizeHubConnection such as AuthorizeAttribute are applied to determine whether to allow potential clients to receive messages sent from that hub using a HubContext or a HubConnectionContext. All applicable hub attributes must allow hub connection for the connection to be authorized. Hub and method level attributes that implement IAuthorizeHubMethodInvocation such as AuthorizeAttribute are applied to determine whether to allow callers to invoke hub methods. All applicable hub level and method level attributes must allow hub method invocation for the invocation to be authorized. Optionally, this module may be instantiated with IAuthorizeHubConnection and IAuthorizeHubMethodInvocation authorizers that will be applied globally to all hubs and hub methods.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.AspNet.SignalR.Hubs Namespace