Showing 1 - 10 of 698 Postings (
summary)
Created by Gustaf Neumann, last modified by Gustaf Neumann 12:49 PM, Friday
The richtext-markdown package adds Markdown editing with Write and Preview tabs to OpenACS richtext fields. Authors write Markdown while applications continue to receive an HTML snippet, suitable for existing display and search workflows.
What the editor does
- Marked renders Markdown, including common GitHub-style constructs such as lists, fenced code blocks and tables.
- DOMPurify sanitizes the generated HTML.
- Turndown converts legacy HTML into an editable Markdown representation. Preformatted code and XoWiki references are preserved; structures such as HTML tables may remain HTML when that better preserves their content.
- Automatic format conversion turns existing Enhanced Text, Plain Text and Fixed-width Text into editable Markdown when the author selects HTML to activate the editor. Fixed-width text becomes a fenced code block.
- A source comment accompanies generated HTML so reopening an entry can recover the original Markdown rather than reconstruct it from HTML. If an existing HTML body is unchanged, its original HTML is preserved.
- Image paste in XoWiki stages images for Preview and saves them as child File items, preserving them in page export/import and XoWiki clipboard operations. Native wiki image markup provides labels and sizing.
- Image paste in Forums and News uploads PNG, JPEG and GIF images for private Preview, then saves them as attachments. Administrators enable this separately from editor selection; pasted images support editable display widths and responsive delivery.
- The toolbar uses the site's normal button rendering. Textarea size and theme classes can be supplied through the usual widget configuration.
This HTML-backed editor is distinct from the Markdown Text MIME choice, which stores text/markdown. Selecting that format does not by itself activate this widget.
Installation and versions
Install richtext-markdown through the Package Manager. It is currently a preview package. For the integrations described below, including image paste in XoWiki, Forums and News, use these versions or newer:
| Package |
Version |
| richtext-markdown |
0.1d3 |
| ACS Kernel |
6.0.0d10 |
| ACS Tcl |
6.0.0d15 |
| ACS Templating |
6.0.0d12 |
| ACS Subsite |
6.0.0d7 |
| Attachments |
0.14.2 |
| Forums |
1.4.3d2 |
| News |
6.0.0d3 |
| XoWiki |
6.0.0d11 |
Use the application versions above for the integrations you need. Upgrade package metadata as well as Tcl files so the new instance parameters are registered. Reload changed Tcl libraries or restart the server when deploying the updated packages. The ACS Kernel upgrade adds srcset and sizes to the allowed HTML attributes; restart after that upgrade to clear cached parameter values.
The package's sitewide administration page shows configured library versions, CDN/local status, registered resource URNs, download controls and links for version pinning and vulnerability information. Merely opening that page does not install the libraries locally. See also Managing Versions of External JavaScript Libraries.
Classical ACS Templating: select the editor for one field
An application can explicitly select Markdown in its ad_form specification, without enabling richtext editing throughout the site:
ad_form -name example -form {
{body:richtext(richtext),optional
{label Body}
{htmlarea_p 1}
{options {editor markdown}}
{html {rows 24 cols 80}}
}
} -on_submit {
set contents [template::util::richtext::get_property contents $body]
set mime_type [template::util::richtext::get_property format $body]
# Save contents and mime_type through the application's existing API.
}
Render the form in the ADP template as usual:
<formtemplate id="example"></formtemplate>
The explicit htmlarea_p 1 enables the editor for this field even when ACS Templating's UseHtmlAreaForRichtextP is disabled. editor markdown selects the plugin independently of the site default. When loading an existing value, provide the normal richtext pair consisting of its content and stored MIME type. On submission, save both returned properties; do not assume the body is raw Markdown or hardcode a different format.
Keep the format selector and activate only for HTML
For a field that should initially offer the standard format choices, use this options entry instead:
{options {editor markdown format_selector 1}}
Keep htmlarea_p 1 in the field specification. The selector remains visible. HTML activates Write/Preview; Enhanced Text, Markdown Text, Plain Text and Fixed-width Text retain their normal editing and storage semantics until the author chooses HTML. An explicit htmlarea_p 0 disables editor activation for that field.
XoWiki
XoWiki has its own editor selection, separate from ACS Templating's site defaults. Set XoWiki's global package parameter PreferredRichtextEditor to markdown to use it as the default XoWiki richtext editor.
Select the editor for a form field
XoWiki provides ::xowiki::formfield::richtext::markdown as an editor class for richtext form fields. Select it through editor=markdown in a form's Form constraints, for example:
_text:richtext,editor=markdown,rows=24
Here _text is the body field used by a typical XoWiki FormPage; use the appropriate field name for other richtext fields. The rows=24 option sets a 24-line textarea; the explicit editor choice overrides the XoWiki default.
With XoWiki 6.0.0d10 or newer, the default menubar also provides New → Markdown Page when richtext-markdown is installed. It uses a dedicated Markdown form. See XoWiki: Customizing the menubar for folder menu configuration.
Increase the height for ordinary wiki pages
For the classical wiki page editor, use the XoWiki instance's WidgetSpecs setting. For example, on a Bootstrap-themed site:
*,text {richtext(richtext),nospell,optional
{label Content}
{htmlarea_p 1}
{options {editor markdown}}
{html {rows 24 class form-control}}
}
WidgetSpecs is a Tcl list of alternating pattern/specification pairs. The widget type must immediately follow the specification's opening brace, as shown: a leading newline there produces a different first token. Do not wrap the entire parameter value in another pair of braces.
The first matching specification wins. Modify an existing *,text entry, or put a page-specific entry such as en:require-post,text before the wildcard entry. Retain other options required by the installation. form-control supplies the normal Bootstrap styling and full width; adapt the class for another theme.
Paste images into XoWiki pages
With XoWiki 6.0.0d11 or newer, select the Markdown editor as described above, open a new or existing page, and paste a PNG, JPEG or GIF image into the Write tab. The normal page creation and editing permissions apply. There is no separate XoWiki image-paste switch corresponding to the Forums controls or News' AllowImagePasteP parameter.
Images pasted into a new page are staged privately until the page is saved, and Preview can display them before the first save. On save, XoWiki stores each image as a child File item of the page. These are native XoWiki child resources, rather than files stored through the Attachments service. Deleting the page deletes its child images. Page export/import and XoWiki clipboard copy/paste include the child files, so the images travel with the page when it is moved between folders or instances using those operations.
The saved reference uses XoWiki's portable child-image markup. Keep the generated filename, and add a label and width option to control its appearance:
[[.SELF./image:pasted-317851.png|Chart|-width 200px]]
Here pasted-317851.png is an illustrative filename; use the name generated for your image. Chart supplies the image description, and -width 200px sets its displayed width. Include the CSS unit, such as px or %; a bare number is not a valid CSS width for this markup. Leave the height unspecified to preserve the aspect ratio. Preview honors the label and dimensions as well as the saved page.
These XoWiki sizing options control display size. They do not use the Forums and News responsive attachment variants described below.
Activate News and Forums without enabling site-wide richtext
Open the Parameters page for each News or Forums instance you want to configure and set:
RichTextEditor = markdown
Leave ACS Templating's site-wide UseHtmlAreaForRichtextP at 0 and its default RichTextEditor unchanged. The instance parameter selects the editor locally; explicit field options take precedence. An empty instance parameter preserves the existing ACS Templating behavior.
The author workflow is:
- Open a new post, reply, news article or revision. The textarea and format selector remain available for non-HTML content.
- Select HTML to activate the Markdown editor without reloading the page.
- Write Markdown, use Preview, and submit through the application's normal form.
Existing HTML entries open directly in the editor. The automatic conversion described in the feature list also applies to existing drafts. For Markdown Text, the editor uses Marked directly and preserves the exact Markdown source.
Switching between formats retains a separate draft for each choice while the form remains open; only the currently selected draft is submitted. If conversion fails, the original text and format remain selected. These settings do not rewrite existing database entries or force Markdown on every new post.
Enable image paste in Forums and News
Install and enable the shared Attachments service. No Attachments child mount or File Storage folder mapping is required. Image paste also requires richtext-markdown to be installed and selected as the editor, with HTML as the content format. Enabling image paste alone does not activate the editor; site-wide richtext editing can remain disabled.
Forums: enable image paste for each forum
Keep RichTextEditor = markdown on the Forums package instance. In Forums administration, create or edit each forum and configure its independent controls:
- Allow image paste: Yes permits signed-in authors to paste PNG, JPEG and GIF images into posts and replies.
- Allow file attachments: No allows image paste without also offering general file uploads. Enable this separately only where general attachments are wanted.
Both controls default to No for new forums. The package instance's AttachmentStyle=simple uses the shared Attachments service directly for general file uploads; image paste uses the direct workflow with either attachment style.
Upgrade note: review Allow file attachments for existing forums after upgrading to Forums 1.4.3d2. Earlier code incorrectly required a child-mounted Attachments instance even for the simple workflow, which could hide upload controls despite an enabled setting. The upgrade preserves existing file-attachment settings, so the fix can make general file uploads available. Set Allow file attachments to No where only image paste is intended. Existing forums initially have image paste disabled and must opt in.
News: enable image paste for the package instance
On the News instance's Parameters page, set:
RichTextEditor = markdown
AllowImagePasteP = 1
AllowImagePasteP defaults to 0. It controls both new articles and new revisions; authors still need the normal News creation or administration permissions. Images are attached to the article's item ID, so they remain available across revisions and are deleted with the article.
Pasting and saving images
Select HTML, put the cursor in the Write tab, and paste an image from the clipboard. The image appears in Preview before saving. Before save, staged images are private to the uploader; saving the post or article attaches them to its content. Abandoned uploads expire automatically.
Disabling image paste blocks new uploads and saving staged images, including from a form opened before the setting changed. Images already attached to posts or articles remain viewable. Without the Markdown editor loaded, the HTML choice provides an HTML-source textarea and does not upload clipboard images. Ordinary file attachments and existing content formats remain independent.
Image sizing and responsive delivery
For Forums and News, pasting inserts an HTML <img> tag in the Write tab, with an editable width attribute. To display the image at 200 pixels wide, change that attribute to width="200". Leave the height unset to preserve its aspect ratio. For example, with an illustrative Forums image URL:
<img src="/forums/markdown-image?key=...&image_width=1200&image_height=600"
alt="Chart" width="200">
Keep the actual src produced by paste; do not replace its image key or ID with the placeholder shown above. Edit alt for a useful image description. The URL's image_width and image_height describe the original dimensions and must be left unchanged; they are not display-size controls.
The editor generates srcset and sizes for Preview and saved HTML, allowing the browser to select an image suited to its viewport and display density. The shared Attachments helper provides cached variants at 320, 640, 960, 1280 and 1920 pixels, preserving aspect ratio and never enlarging the original. New uploads carry the dimension information needed for this; existing saved posts are not automatically rewritten.
Server-side resizing requires ImageMagick, configured through the Content Repository's ImageMagickConvertBinary parameter (default: convert). If conversion is unavailable, busy or fails, delivery falls back to the original. Original files are retained, and the image URL without a width query parameter serves the original. That query parameter selects a server variant and is distinct from the HTML width attribute used for display sizing.
XoWiki continues to use its native wiki image markup and sizing options; the Forums and News example above does not change that workflow.
Permissions and content handling
Image delivery, including cached variants, checks the application's content visibility and permissions. The editor's sanitized HTML remains subject to the application's normal permissions and content handling.
Created by Gustaf Neumann, last modified by Gustaf Neumann 06:01 PM, Wednesday
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:
- reject the unknown user
- 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
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
}
Created by Gustaf Neumann, last modified by Gustaf Neumann 05:52 PM, Wednesday
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
Created by Gustaf Neumann, last modified by Gustaf Neumann 05:50 PM, Wednesday
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
Created by Gustaf Neumann, last modified by Gustaf Neumann 05:40 PM, Wednesday
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.
Created by Gustaf Neumann, last modified by Gustaf Neumann 23 Feb 2026, at 06:28 PM
This recipe shows how to enforce POST for state-changing endpoints and how it fits with CSRF protection in OpenACS.
Motivation
State-changing operations (e.g., create/update/delete actions, membership or role management, administrative tasks) should not be reachable via HTTP GET requests.
GET requests are easy to trigger unintentionally or via social engineering (for example by clicking a link in an email). In modern browsers, session cookies with SameSite=Lax are still sent on cross-site top-level GET navigations, which makes such endpoints vulnerable to CSRF-style attacks if no additional protection is in place.
To reduce this attack surface, OpenACS applications can explicitly require HTTP POST for state-changing requests.
The ::template::require_post validator
The procedure ::template::require_post enforces that the current request uses the HTTP POST method. If the request is issued using any other method (typically GET), it returns a 405 Method Not Allowed response and aborts request processing.
This validator is intended to be used in the -validate blocks of ad_page_contract and ad_form.
Example A: Using require_post in ad_page_contract
ad_page_contract {
...
} -query {
email ...
} -validate {
method { require_post }
csrf { csrf::validate }
}
# Page implementation follows
In this example:
Placing the method check early in the validation phase ensures that invalid requests are rejected before any state-changing logic is executed.
Example B: Using require_post in ad_form
# If the data is not submitted via a POST request, bail out hard.
# The request might originate from a forged or unintended request.
ad_form \
-name myform \
-form {
{email:text {label "E-Mail"}} ...
} -validate {
{email
{ [require_post] }
"Only POST requests are allowed"
}
} -on_submit {
...
}
This pattern attaches the POST requirement directly to the form validation phase and ensures that the form submission cannot be triggered via a simple GET request.
Caveat: POST is not sufficient by itself
Requiring POST does not replace CSRF protection.
A determined attacker can still trigger cross-site POST requests (for example via auto-submitted forms). Proper CSRF protection therefore must include explicit CSRF token validation.
Requiring POST should be understood as a defense-in-depth measure:
-
It prevents accidental or link-based triggering of state-changing actions.
-
It improves the effectiveness of SameSite=Lax cookies.
-
It reduces the risk of subtle CSRF bugs caused by overlooked GET endpoints.
For full protection, state-changing endpoints should:
-
Require POST
-
Validate a CSRF token
-
(Optionally) perform "Origin" or "Referer" checks for high-risk administrative actions
When to use this pattern
Use require_post for:
-
administrative pages (e.g., under /admin)
-
role or permission changes
-
membership management
-
any operation that modifies server-side state
Do not use require_post for:
-
read-only pages
-
bookmarkable navigation URLs
-
search, filtering, or pagination endpoints
See also
Created by Gustaf Neumann, last modified by Gustaf Neumann 23 Feb 2026, at 05:08 PM
The newest versions of OpenACS (head) and NaviServer (5.1) can now process JSON request bodies in the same convenient way as classic HTML form submissions. When a request is sent with a JSON media type (including structured suffix types such as application/*+json), NaviServer parses the JSON payload automatically and flattens it into the connection form set. This enables using ad_page_contract for validation and makes JSON requests first-class citizens in existing OpenACS applications.
On validation failures, OpenACS can return a standards-based error response using RFC 9457 (application/problem+json) and can include JSON Pointer references (RFC 6901) to pinpoint the offending fields.
Overview
- Automatic JSON parsing: JSON request bodies are parsed and exposed through
ns_getform/ns_conn form as an ns_set.
- Typed values: The flattened representation includes
.type sidecar keys (e.g., user/id.type, user/flags/admin.type) to preserve JSON typing.
- JSON Pointer addressing (RFC 6901): When reporting errors (and when navigating typed JSON structures via the
ns_json triples ensemble), JSON Pointer provides an interoperable path syntax such as /user/flags/admin.
- Problem Details errors (RFC 9457): Contract violations for JSON requests can return
422 Unprocessable Content with application/problem+json.
Sending JSON Requests
Clients should send JSON with an appropriate Content-Type header:
Content-Type: application/json
Structured syntax suffixes are supported as well:
Content-Type: application/vnd.api+json
Using ad_page_contract with JSON
In OpenACS, you can validate JSON-derived values using ad_page_contract. Because the JSON body is flattened into an ns_set, contract parameter names can refer to nested JSON fields using a slash-separated naming convention.
Example OpenACS page
ad_page_contract {
test_page
} {
{user/id:naturalnum 0}
{user/flags/admin:boolean}
}
ns_return 200 application/json [subst {{"result":"OK", "user_id":${user/id}}}]
The contract declares two inputs:
user/id must be a natural number (integer >= 0) and defaults to 0
user/flags/admin must be a boolean
Example Request Payload
Submitted JSON data:
{"user": {
"id":-7,
"name":"Alice",
"flags":{
"admin":"xxx",
"active":true
}}
}
Validation Failure Response (RFC 9457 + RFC 6901)
When the request body was parsed as JSON and validation fails, OpenACS can return a Problem Details document (application/problem+json) with status 422. Each error includes a JSON Pointer fragment (#/...) referencing the offending field in the request document.
{
"type": "https://openacs.org/validation-error",
"title": "We had a problem with your input:",
"status": 422,
"errors": [
{
"detail": "user/id is not a natural number, that is an integer greater than or equal to 0.",
"pointer": "#/user/id"
},
{
"detail": "user/flags/admin does not appear to be a Boolean value.",
"pointer": "#/user/flags/admin"
}
]
}
Notes
- The
type field is a stable identifier (a URI) for the class of problem. It may be used by clients for automatic handling and may also point to documentation.
- The
title and detail fields are intended for humans and may be localized. Clients should not rely on localized text for program logic.
- The
pointer values use JSON Pointer fragment identifiers (#/...), consistent with the Problem Details ecosystem. The corresponding JSON Pointer path without fragment prefix would be /user/id, /user/flags/admin, etc.
Optional: Typed JSON Navigation with ns_json triples
For applications that need to navigate and update JSON while preserving JSON types (numbers, booleans, null, arrays, objects), NaviServer provides the ns_json triples ensemble. It supports addressing via Tcl list paths or JSON Pointer (RFC 6901) and can generate JSON output directly from triples without lossy conversions. Alternatively of using the ns_set provided by ns_getform, one can get the body of the request and process the included JSON, extract parts of it, etc.
Typical flow:
set t [ns_json parse -output triples $json]
ns_json triples getvalue -pointer /user/flags $t
set t2 [ns_json triples setvalue -pointer /user/flags/admin -type boolean $t true]
ns_json triples getvalue -pretty -pointer /user/flags $t2
See Also
Created by Joel Aufrecht, Gustaf Neumann, Michael Aram, Dafydd Crosby, Emmanuelle Raffenne, Carl Robert Blesius, Torben Brosten, Robert Taylor, OpenAI Codex, last modified by Michael Aram 05 Jan 2026, at 10:58 PM
OpenACS requires, at a minimum, an operating system, database, and web server to work. Many additional programs, such as a build environment, Mail Transport Agent, and source control system, are also needed for a fully effective installation.
Table 2.2. Version Compatibility Matrix
| OpenACS Version |
3.2.5 |
4.5 |
4.6 |
4.6.1 |
4.6.2 |
4.6.3 |
5.0 |
5.1 |
5.2 (core) |
5.3 (core) |
5.4 (core) |
5.5 (core) |
5.6 (core) |
5.7 (core) |
5.8 (core) |
5.9.0 (core) |
5.9.1 (core) |
5.10.0 (core) |
5.10.1 (core) |
| AOLserver |
3 |
Yes |
No |
No |
| 3.3+ad13 |
Maybe |
Yes |
No |
No |
| 3.3oacs1 |
Maybe |
Yes |
No |
No |
| 3.4.4 |
No |
No |
| 3.4.4oacs1 |
Maybe |
Yes |
No |
No |
| 3.5.5 |
Maybe |
Yes |
No |
No |
| 4.0 |
Maybe |
Yes |
No |
No |
| 4.5 |
No |
Yes |
No |
No |
| 4.5.2 |
No |
Yes |
No |
| NaviServer |
4.99.4 - |
No |
Maybe |
Yes |
Yes |
| 5.0 - |
No |
Maybe |
Yes |
Yes |
| Tcl |
8.4 |
Yes |
No |
No |
| 8.5.4 - |
Maybe |
Yes |
No |
| 8.6.7 - |
No |
Maybe |
Yes |
Yes |
| 9.0 - |
|
| XOTcl |
1.6 - |
Yes |
No |
No |
| 2.0 - |
No |
Yes |
Yes |
| PostgreSQL |
7.4 |
No |
Yes |
No |
No |
| 8.0 |
No |
Maybe |
Yes |
Maybe |
No |
No |
| 8.1 |
No |
Yes |
Maybe |
No |
No |
| 8.2 |
No |
tar: no, CVS: Yes |
Yes |
Maybe |
No |
No |
| 8.3 |
No |
Yes |
Maybe |
No |
No |
| 8.4 |
No |
Yes |
No |
No |
| 9.0 |
No |
Yes |
Mostly |
No |
| 9.2 |
No |
Mostly |
yes |
Mostly |
No |
| 9.4 |
No |
Mostly |
yes |
No |
| 11 |
No |
CVS: yes |
Yes |
No |
| 12 - |
No |
Yes |
| 13 - |
No |
Yes |
| 14 - |
No |
Yes |
| Oracle |
8.1.6 |
Maybe |
Yes |
Maybe |
Maybe |
| 8.1.7 |
Maybe |
Yes |
Maybe |
Maybe |
| 9i |
No |
Yes |
Maybe |
Maybe |
| 10g |
No |
Yes |
Maybe |
Maybe |
| 11g |
No |
Maybe |
Maybe |
| 19c |
|
Yes |
The value in the cells correspond to the last version of that release, and not necessarily to all minor releases. Empty cells denote an unknown status.
Created by Gustaf Neumann, last modified by Michael Aram 14 Dec 2025, at 10:25 PM
NaviServer is a fork of AOLserver. While the goal of the AOLserver community is stability (no code changes unless necessary), NaviServer is targeted toward further development and extensions (implementing new features required by state of the art web server environments, see NEWS).
Availability
Using NaviServer with OpenACS
Created by Gustaf Neumann, last modified by Gustaf Neumann 20 Jul 2025, at 09:48 AM
- Copenhagen, April 11, 2003
- Heidelberg, April 23-28, 2004
- Madrid, May 9-11, 2005
- Boston, November 1-3, 2006
- Vienna, April 25-28, 2007
- Guatemala City, February 12-16, 2008
- Valencia, November 18-19, 2008
- Costa Rica, November 3-6, 2009
- Vienna, June 30 and July 1, 2022
- Vienna, July 20-21, 2023
- Vienna, July 11-12, 2024
- Bologna, July 10-11, 2025