You are here

Creating a Hello User web script with authentication

To see authentication in action, you can make a slightly more interesting Hello World example named Hello User that requires authenticated access and responds with a personalized greeting.
  1. Log in to Alfresco Share.
    1. Type http://localhost:8080/share in the web browser.
    2. If prompted, log in with the user name admin and password admin.
    3. Click the Repository link in the Share header.
    4. Navigate to Data Dictionary > Web Scripts Extensions.
  2. Create a web script description document for the Hello User example.
    1. In the Create menu, select XML.
    2. Enter hellouser.get.desc.xml as the web script name in the Name field.
    3. Enter the following in the content box:

        <shortname>Hello User</shortname>
        <description>Personalized greeting</description>
        <negotiate accept="text/html">html</negotiate>
        <negotiate accept="application/json">json</negotiate>
    4. Click Create.
    5. Click the Web Scripts Extensions directory again to return to the folder.
  3. Create a web script response template to render the Hello User greeting.
    1. In the Create menu, select Plain Text.
    2. Enter hellouser.get.html.ftl as the template name in the Name field.
    3. Type Hello ${} in the content box.
    4. Click Create.
    5. Again, navigate back to the Web Scripts Extensions folder by clicking on it in the breadcrumb trail.
  4. Register the Hello User web script with Alfresco.
    1. Open a new browser tab.
    2. Type http://localhost:8080/alfresco/service/index in the web browser.
    3. If prompted, log in with the user name admin and password admin.
    4. Click Refresh Web Scripts.

      A message indicates there is one additional web script.

  5. Type http://localhost:8080/alfresco/service/hellouser in the web browser to test the new web script.

    A Hello admin message displays indicating your web script is working.

Sending feedback to the Alfresco documentation team

You don't appear to have JavaScript enabled in your browser. With JavaScript enabled, you can provide feedback to us using our simple form. Here are some instructions on how to enable JavaScript in your web browser.