View · Search · Index

Weblog

Filtered by date 2026-11-25, 1 - 4 of 4 Postings (all, summary)

Using OpenACS with External Identity Providers

Created by Gustaf Neumann, last modified by Gustaf Neumann 25 Nov 2026, at 06:01 PM

With the forthcoming version, OpenACS 5.10.1 (and the current head version in the oacs-5-10 branch) OpenACS provides support for external identity providers, which can be used in parallel to the existing OpenACS authorities. It is possible, that users can

  • login alternatively via the configured authority and/or via external identity providers, or
  • exclusively over external identity providers

The alternative login requires that the same email address is used for a user in OpenACS and on the identity provider.

Handling of unregistered users

When using alternative logins, the returned user information might match pre-existing OpenACS users, or user information, which is unknown to the system. In such a situation, three scenarios might be possible:

  1. reject the unknown user
  2. create a new OpenACS user based on the information returned from the identity provider.

The default behavior of the implementation is to reject the user. When the optional flag "-create_not_registered_users" is activated for an external provider, such users will be created. When creating users (e.g. in dotlrn), it is also possible to add these automatically to certain dotlrn groups (specified in "create_with_dotlrn_role"). Further behavior might be specified by extending the predefined behavior (see example below).

Supported external identity providers for alternative logins

Currently, the following (OAuth 2 based) identity providers are supported

  • Microsoft Identity Platform (based on ID-Tokens) based on Azure and Active Directory
  • GitHub

OpenACS allows defining one or more identity handlers by defining either different login-handler objects for the same identity provider (e.g. for use on different subsites) to by defining login-handler objects for different identity providers (maybe also for the same subsite).

To enable the external identity providers, the package xooauth has to be installed and one or more external identity providers must be configured on the side of the provider service (to allow its usage for the OpenACS instance) and on the OpenACS instance. So, make sure xooauth is installed and mounted on /oauth (the mount path is relevant for the Redirect URI below).

Microsoft Identity Platform

  • Configuration on the provider side:
    • Register application via the Azure Portal
    • Set the Redirect URI type to Web and value pointing to the redirect page (e.g. YOURLOCATION/oauth/www/azure-login-handler)
    • In this process you will obtain the "tenant_id", "client_id" and a "client_secret"
    • Microsoft supports its ID token interface in version v1.0 and v2.0. When v2.0 is configured on the OpenACS side (see below), make sure to define in the "Token configuration" the optional claims "upn", "family_name", and "given_name" (latter two only, when allowing automatic account creation).
    • Details: Add sign-in with Microsoft to a web app, Microsoft identity platform ID tokens

     

  • Configuration on OpenACS
    •   Create a login-handler object (e.g. in xooauth/tcl/oauth-init.tcl)  

      ms::Authorize create ms::azure
          -tenant "..." \
          -client_id "..."
      

      Potential further parameters:

              -responder_url "..."  (default "/oauth/azure-login-handler")
              -debug
              -create_not_registered_users
              -create_with_dotlrn_role "..."
              -after_successful_login_url "..."
              -login_failure_url "..."  

    • The interface is based on the same infrastructure as the Microsoft Graph interface of OpenACS.

    • For the full list of parameters, see the online documentation of the ms::Authorize class.

Using GitHub as Identity Provider

  • Configuration on the provider side:

    • Register application on GitHub: login on GitHub (with e.g. your ID), goto "Settings", "Developer Settings", "OAuth Apps", "Register a new application"
    • Set the Redirect URI: When registering the application, fill in the value of "Authorization callback URL" to YOURLOCATION/oauth/www/github-login-handler
    •  Details: Authorizing OAuth Apps
  • Configuration on OpenACS

    • Create a login-handler object (e.g. in xooauth/tcl/oauth-init.tcl)

      xo::oauth::GitHub create ::xo::oauth::github \
          -client_id "..." \
          -client_secret "..."
      

      Potential further parameters:

             -responder_url "..."   (default "/oauth/github-login-handler")  
             -debug  
             -create_not_registered_users  
             -create_with_dotlrn_role "..."  
             -after_successful_login_url "..."  
             -login_failure_url "..."
      
    • For the full list of parameters, see the online documentation of the GitHub class.

The parameters -debug, -create_not_registered_users and -create_with_dotlrn_role ... are common parameters and control the behavior.

  • When the switch -debug is specified, the interface page (e.g. /oauth/github-login-handler) can be used for testing and to see the provided parameters ("claims") returned from the identity provider. In the testing mode, the user is not logged-in. Furthermore, on the public login pages of the OpenACS instance, the external entity is not offered.  
  • When the switch -create_not_registered_users is specified, the users authorized via the external identity provider not existing as users in OpenACS (based on the email address) are automatically created as new OpenACS users (automated account creation). By default, this switch is turned off.   
  • The parameter -create_with_dotlrn_role ... is useful for DotLRN instances. When it is defined, new users will be created as DotLRN users with the specified role (e.g. student).

The configuration parameter can be provided when the login-handler objects are created, or these can be provided via the OpenACS configuration file. The parameters are looked up from the configuration file on a path based on the name of the login-handler object. So, with the following login-handler objects are defined

     ::ms::Authorize create ::ms::azure
     ::xo::oauth::GitHub create ::xo::oauth::github

the parameters for these objects can be specified during
creation (.... -client:id "..." ...) or in the
configuration file in the following sections:

      ns/server/[ns_info server]/acs/oauth/ms/azure {
         ns_param tenant "..."
         ns_param client_id "..."
         ...
      }
      ns/server/[ns_info server]/acs/oauth/github {
         ...
      }

the parameters for these objects can be specified during creation (.... -client_id "..." ...) or in the configuration file in the following sections:

       ns/server/[ns_info server]/acs/oauth/ms {
          ...
       }

Testing

For testing, it is recommended to define the login-handler objects with the optional "-debug" flag (see above). Add the login-handler object with the following command in xooauth/tcl/oauth-init.tcl file

      xo::oauth::GitHub create ::xo::oauth::github \
          -debug

This assumes that the GitHub as Identity Provider was defined on GitHub, and at least the parameters "client_id" and "client_secret" are defined in the OpenACS configuration file.

Then restart the server and navigate to YOURLOCATION/oauth/github-login-handler and you will see the option to login via GitHub. By clicking on the link, you will be redirected to GitHub for registering, and then you will be redirected to the interface page showing the claims provided by GitHub, and whether the user_id exists, etc.

When the login-handler objects are created without the "-debug" flag, the login options for all the created login-handler objects are listed on the register/login page of OpenACS (it is possible to omit these via a package parameter set on a subsite).

Example configuration with a custom login handler

Example for xooauth/tcl/oauth-init.tcl:

#
# Potential place for creating login-handler objects for external
# identity providers.
#
# xo::oauth::GitHub create ::xo::oauth::github \
#    -client_id "..." \
#    -client_secret "..."
#
# ms::Authorize create ms::azure \
#    -tenant "..." \
#    -client_id "..."
#

#
# This is a custom login handler, 
# - configured to create unregistered users,
# - using the "tenant" and "client_id" from the configuration file, and
# - adding some site-specific actions after a successful registration
#
ms::Authorize create ms::LoginHandler -create_not_registered_users
ms::LoginHandler object method register_new_user {
    {-first_names}
    {-last_name}
    {-email}
} -returns integer {

    # perform first the "register_new_user" action as usual
    set user_id [next]

    # on successful registrations (no exception during "next") the user_id is returned.
    # Do whatever you want with this user_id, adding it to groups, etc.
    ns_log notice "ms::LoginHandler: new registration of user $email returned user_id $user_id"

    return $user_id
}

Managing Versions of External JavaScript Libraries

Created by Gustaf Neumann, last modified by Gustaf Neumann 25 Nov 2026, at 05:52 PM

This page describes the requirements for managing packages with external libraries.

Requirements:

  •  R1) Make it possible for users to use always the newest version
  •  R2) Make it possible to pin a version number, although a newer default version is configured by OpenACS
  •  R3) It should be possible to copy the database of the production instance to a staging instance without affecting the version number of the external library on the staging instance. The version number on the staging instance might be different to the production site.

When a version is pinned, the site administrator has to change the version number manually, when an upgrade is desired.

OpenACS policy:

The "newest" version is the default version as configured into a package. When upgrading the package, the "newest" version might change.

How to pin a version number:

  • Pin version number via configuration file: This works exactly like setting other package parameters via configuration files. Check out the instructions on the site-wide admin page of the package.
  • Pin version number via package parameter: The easiest way is to add the parameter via the site-wide admin page. It is always possible to modify the parameter this way or to remove the package parameter (i.e., switch to R1).

Site policies:

Always get the newest tested version tested upstream (use default versions, R1)

  • do not pin the version number via package parameter or via configuration file

Set a different version on the production site than on staging/testing instances:

  • Pin the version number via configuration file on the production instance (R2, R3)

  • On the testing instances, you can use the default version, or fix the version number via configuration file or global package parameter.

Use always the same fixed version number on production and staging/testing instances

  • pin via global package parameter (R2)

Packages following these principles in the oacs-5-10 branch

These principles are implemented for the following packages:

  • bootstrap-icons
  • fa-icons
  • highcharts
  • openacs-bootstrap5-theme
  • richtext-ckeditor4
  • cookie-consent
  • openacs-bootstrap3-theme
  • richtext-tinymce

Security: Cross Site Request Forgery (CSRF)

Created by Gustaf Neumann, last modified by Gustaf Neumann 25 Nov 2026, at 05:50 PM

Starting with OpenACS 5.9.1, OpenACS offers support for protecting against Cross Site Request Forgery (CSRF). In essence, this attack can cause a user’s web browser to perform an unwanted action on a trusted site for which the user is currently authenticated. The user gets a page presented, which looks harmless, but contains links or images that perform actions with the users credentials without the users consent. Note that the CSP does not protect a user against clicks on a malicious link.

CSRF protection works by ensuring that values for an action (e.g. by from a HTML form) are only accepted from a user that has received the form before. OpenACS generates by its security-procs a secure CSRF token value and provides it to a developer it in a global variable ::__csrf_token. When requests secured with the CSRF token are received, it can be validated on the server side. Note, that this mechanism is similar to "signing" values in OpenACS.

CSRF protection concerns of two parts: add the CSRF token to the form (POST requests) or to the href, and checking the received in the queries expecting input from CSRF protected resources. The first part works technically quite similar as securing CSP via nonces. Add code to the Tcl or ADP page that outputs the global variable (the test for the token is mostly for backwards compatibility)

    <form ...>
        ...
        <if @::__csrf_token@ defined>
           <input type="hidden" name="__csrf_token" value="@::__csrf_token;literal@">
        </if>
        ...
    </form>

Secondly, the page contract on the receiving side has to validate the csrf token. This can be achieved by adding a call to csrf::validate to the validation part of a page contract.

    ad_page_contract {
        @author ...
        @creation-date ...
    } -query {
       ...
    } -validate {
       ...
       csrf { csrf::validate }
    }

In the code base of OpenACS, CSRF protection was added on several places (e.g. public pages, the list template, etc.) such the checks of OpenACS sites on vulnerability scanners improve. Technically, it would be desirable to secure more places against CSRF attacks in the future. However, it depends on the requirements of a site whether e.g. the API browser or search should be CSRF protected. With protection turned on, one cannot share e.g. a link to a search with some other user (or a search engine). A site admin has to decide, how protected/public such links should be.

When using ad_form, the inclusion of the csrf token is done most conveniently via the  -csrf_protection_p flag:

    ad_form \
        ... \
        -csrf_protection_p true

XoWiki: Customizing the menubar

Created by Gustaf Neumann, last modified by Gustaf Neumann 25 Nov 2026, at 05:40 PM

XoWiki's default menubar is defined in packages/xowiki/tcl/menu-procs.tcl. The method ::xowiki::MenuBar config=default creates the menus; config_menu=New supplies the standard creation links. Entries use names such as New.Page: the first component identifies the menu.

Recommended workflow: Edit Folder

The following steps are the recommended workflow for XoWiki version 6.0.0d10 or newer.

When the menubar is enabled, open the menu bearing the wiki instance's name and choose Edit Folder. Set the folder's extra_menu_entries field and save. This is the same workflow for the root folder and subfolders; no additional package parameter needs to be configured.

The action edits the current folder's FormPage, using its existing edit permissions. At the top level it explicitly targets the root folder, even when the wiki displays en:index. This Page → Edit continues to edit the displayed page. Folder settings apply to the menubar rendered for that folder; repeat the configuration for other folders as needed.

For example, add this specification to extra_menu_entries:

{entry -name New.MyPage -label {My Page} -form en:my-page.form}

The form must exist or be available as a prototype. XoWiki uses make_form_link to resolve it and create a link with the current folder, language and return URL, using the usual permission checks. Other targets include a direct URL or a legacy page class:

{entry -name Package.Help -label Help -link /xowiki/help}
{entry -name New.PlainPage -label {Plain Page} -object_type ::xowiki::PlainPage}

A stable entry name updates an existing entry rather than duplicating it. An explicit -label supplies the text; otherwise XoWiki looks for a message key such as xowiki.menu-New-MyPage or xowf.menu-New-MyPage.

Where the default New entries come from

The list is built by ::xowiki::MenuBar config_menu=New in tcl/menu-procs.tcl, not stored separately in each folder. The standard entries are Page, File, Folder and New Form, plus Symbolic Link when configured. XoWiki 6.0.0d10 extends this list with Markdown Page immediately after Page when richtext-markdown is installed. It therefore appears automatically in each default menubar.

The Markdown entry uses en:markdown.form, whose body constraint is _text:richtext,editor=markdown. This explicitly selects Markdown independently of the preferred richtext editor.

Replacing a menu

To replace the contents of the New menu, clear it first and then list the desired entries:

{clear_menu -menu New}
{entry -name New.Page -label Page -form en:page.form}
{entry -name New.File -label File -object_type ::xowiki::File}

XoWiki creates the default menus first and then applies the current folder's extra_menu_entries. These values are Tcl lists of specifications, not Tcl scripts; do not place executable conditionals in them. Clearing the New menu replaces the defaults, including the automatic Markdown entry. Include an entry for en:markdown.form explicitly if a replacement menu should retain it.

Conditional entries in Tcl

A package-dependent default entry belongs in the menu-building method. For example, the development version of XoWiki adds Markdown Page after Page only when richtext-markdown is installed:

if {[apm_package_installed_p richtext-markdown]} {
    set link [::$package_id make_form_link \
                  -form en:markdown.form \
                  -parent_id ${:parent_id} \
                  -return_url $return_url]
    :add_menu_item -name New.MarkdownPage -item [list url $link]
}

The prototype resources/prototypes/markdown.form.page uses the field constraint _text:richtext,editor=markdown. The explicit editor setting makes this choice independent of PreferredRichtextEditor. Content is stored as HTML by the richtext editor. The prototype is imported through the normal form-resolution mechanism when needed.

After updating the Tcl source, reload it through the package manager or restart the server. Import the updated XoWiki message catalogs for translated labels. A customized New menu that clears the defaults must explicitly include the desired Markdown entry.

previous November 2026
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 (4) 25 26 (1) 27 28
29 30 1 2 3 4 5

Popular tags

17 , 5.10 , 5.10.0 , 5.10.1 , 5.9.0 , 5.9.1 , ad_form , ADP , ajax , aolserver , asynchronous , Azure , bgdelivery , bootstrap , bugtracker , CentOS , COMET , compatibility , conference , CSP , CSRF , cvs , debian , docker , docker-compose , emacs , engineering-standards , exec , fedora , FreeBSD
No registered users in community xowiki
in last 30 minutes
Contributors

OpenACS.org