Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Security

Security feature. Allows querying and modification of server-side security and authentication configuration.

Example:

// Get a reference to the security feature
var security = session.security;

Hierarchy

  • Security

Implemented by

Index

Properties

GlobalPermission

GlobalPermission: GlobalPermission

The global permission enum

PathPermission

PathPermission: PathPermission

The path permission enum

TopicPermission

TopicPermission: PathPermission

The topic permission enum

deprecated

since 6.5 Replaced with PathPermission

Methods

authenticationScriptBuilder

changePrincipal

  • changePrincipal(principal: string, credentials: string): Result<void>
  • Change the principal associated with this session.

    Allows a session to authenticate as a different principal. If the authentication fails, the current principal remains valid.

    Parameters

    • principal: string

      the new principal to use.

    • credentials: string

      credentials to authenticate the principal with.

    Returns Result<void>

    a Result

    Example:

    session.security.changePrincipal('foo', 'password');

getGlobalPermissions

  • Returns the set of global permissions assigned to the role.

    since

    6.3

    Returns Result<GlobalPermission[]>

    the set of global permissions. This may be empty indicating that the role has no global permissions assigned.

getPathPermissions

  • Returns a list of path permissions assigned to the calling session on a given path.

    since

    6.5

    Parameters

    • path: string

      the path to query for permissions

    Returns Result<PathPermission[]>

    a Result which completes when the response is received from the server.

    If the request was successful, the Result will complete successfully with a list of PathPermission.

getPrincipal

  • getPrincipal(): string
  • Get the principal that the session is currently authenticated as.

    Returns string

    the session's principal

getSecurityConfiguration

  • Obtain the current contents of the server's security store.

    If the request is successful, the result will complete with a SecurityConfiguration.

    Example:

    session.security.getSecurityConfiguration().then(function(configuration) {
        console.log('Got security configuration', configuration);
    }, function(err) {
        console.log('Error getting security configuration', err);
    });

    Returns Result<SecurityConfiguration>

    a Result that completes with the security configuration

getSystemAuthenticationConfiguration

  • Obtain the current contents of the server's authentication store.

    If the request is successful, the success callback will be called with a SystemAuthenticationConfiguration object.

    Example:

    session.security.getSystemAuthenticationConfiguration().then(function(configuration) {
         // Display principals/roles
         configuration.principals.forEach(function(principal) {
              console.log(principal.name, principal.roles);
         });
    
         // Check the authentication action applied to anonymous connections
         console.log(configuration.anonymous.action);
    
         // Check the default roles assigned to anonymous connections
         console.log(configuration.anonymous.roles);
    }, function(err) {
         // Error retrieving configuration
         console.log(err);
    });

    Returns Result<SystemAuthenticationConfiguration>

    a Result that completes with the server's authentication store

getTopicPermissions

  • Returns a list of topic permissions assigned to the calling session on a given path.

    deprecated

    since 6.5. Use {@link #getPathPermissions()} instead.

    Parameters

    • path: string

    Returns Result<PathPermission[]>

    a Result which completes when the response is received from the server.

    If the request was successful, the Result will complete successfully with a list of TopicPermission.

securityScriptBuilder

setAuthenticator

  • Register an authenticator for client authentication events.

    since

    6.3

    Parameters

    • handlerName: string

      the handler name which must match an entry in the server's security configuration

    • authenticator: Authenticator

      specifies the authentication handler

    Returns Result<Registration>

    a Result that completes when the authentication handler has been registered, returning a Registration which can be used to unregister the authentication handler.

    Otherwise, the Result will resolve with an error. Common reasons for failure include:

    • the session is closed;
    • the session does not have REGISTER_HANDLER or AUTHENTICATE permission;
    • the server configuration does not contain a control-authentication-handler element with the given name.

updateAuthenticationStore

  • updateAuthenticationStore(script: string): Result<void>
  • Send a command script to the server to update the authentication store. The script may be produced by the builder SystemAuthenticationScriptBuilder.

    If the script is applied without error to the server, the operation result will complete successfully.

    If any command in the script fails, none of the changes will be applied, and the result will be failed with an error object.

    If the server is configured for path replication then the changes will be replicated to all members of the cluster.

    Example:

    session.security.updateAuthenticationStore(script).then(function() {
        console.log('Authentication configuration updated');
    }, function(err) {
        console.log('Failed to update security configuration', err);
    });

    Parameters

    • script: string

      the command script

    Returns Result<void>

    a Result

updateSecurityStore

  • updateSecurityStore(script: string): Result<void>
  • Send a command script to the server to update the security store. The script may be produced by the builder SecurityScriptBuilder.

    If the script is applied without error to the server, the operation result will complete successfully.

    If any command in the script fails, none of the changes will be applied, and the result will be failed with an error object.

    If the server is configured for path replication then the changes will be replicated to all members of the cluster.

    Example:

    session.security.updateSecurityStore(script).then(function() {
        console.log('Security configuration updated');
    }, function(err) {
        console.log('Failed to update security configuration', err);
    });

    Parameters

    • script: string

      the command script

    Returns Result<void>

    a Result