Most Popular
Recently Added
Recently Updated

Setting Up Basic Auth

Use Case

How to setup basic authentication between nodes.

Solution

Master Node (Registration Node)

  1. At the bottom of your existing {SYM_HOME}/web/WEB-INF/web.xml file, add a security constraint by adding the following lines:
    <security-constraint> <web-resource-collection> <url-pattern>/sync/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>nodeRole</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>default</realm-name> </login-config>
  2. Create a jetty-web.xml with the following contents int the {SYM_HOME}/web/WEB-INF folder. This will add a login service handler.
    <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Get name="securityHandler"> <Set name="loginService"> <New class="org.eclipse.jetty.security.HashLoginService"> <Set name="name">default</Set> <Set name="config"> <SystemProperty name="user.dir" default="."/>/web/WEB-INF/realm.properties </Set> </New> </Set> </Get> </Configure> <p>

  3. Create a realm.properties file with the following contents and put into the {SYM_HOME}/web/WEB-INF folder. This file contains the usernames and passwords needed by nodes to authenticate.

    Note

    The format of the realm.properties is "username: password, role". The role in the realm.properties needs to match the role in the web.xml.


    node: secret,nodeRole
    node2: secret2,nodeRole

    Nodes

  4. Add the following properties to each node. Find the appropriate engine properties file for each node in the {SYM_HOME}/engines/*.properties.
    http.basic.auth.username=node
    http.basic.auth.password=secret
    

Properties ID: 000029   Views: 1550   Updated: 4 years ago
Filed under: