Skip to content

Commit 161e1db

Browse files
committed
Add section on ows_extra_params for MapServer/MapServer#7360
1 parent 56ec623 commit 161e1db

File tree

1 file changed

+76
-17
lines changed

1 file changed

+76
-17
lines changed

en/ogc/ogc_api.txt

Lines changed: 76 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
:Author: Jeff McKenna
1111
:Contact: jmckenna at gatewaygeomatics.com
12-
:Last Updated: 2025-09-11
12+
:Last Updated: 2025-10-10
1313

1414
.. contents:: Table of Contents
1515
:depth: 3
@@ -42,9 +42,9 @@ and the relevant emerging OGC API standards.
4242

4343
.. table::
4444
:align: left
45-
45+
4646
+------------+---------------------+
47-
| WxS | OGC API |
47+
| WxS | OGC API |
4848
+============+=====================+
4949
| OWS Common | OGC API - Common |
5050
+------------+---------------------+
@@ -58,7 +58,7 @@ and the relevant emerging OGC API standards.
5858
+------------+---------------------+
5959
| SLD | OGC API - Styles |
6060
+------------+---------------------+
61-
61+
6262
Requirements
6363
============
6464

@@ -360,17 +360,17 @@ Collections
360360
(JSON) or *ogcapi/collections?f=html* (HTML) such as::
361361

362362
http://127.0.0.1/cgi-bin/mapserv.exe/ + your mapfile alias + /ogcapi/collections?f=html
363-
363+
364364
or in the above example, it would be: ``http://127.0.0.1/cgi-bin/mapserv.exe/localdemo/ogcapi/collections?f=html``
365-
365+
366366
.. image:: ../images/ogcapi-ms4w-collections.png
367367
:width: 400
368368
:class: no-scaled-link
369-
369+
370370
.. TIP::
371371
See a live MapServer 8.0 `OGCAPI: Features` collection at
372372
https://demo.mapserver.org/cgi-bin/mapserv/localdemo/ogcapi/collections?f=html
373-
373+
374374
Collection Items
375375
****************
376376

@@ -380,30 +380,30 @@ Collection Items
380380
http://127.0.0.1/cgi-bin/mapserv.exe/ + your mapfile alias + /ogcapi/collections/ + layername + /items?f=json
381381

382382
or in the above example, it would be: ``http://127.0.0.1/cgi-bin/mapserv.exe/localdemo/ogcapi/collections/lakes/items?f=json``
383-
383+
384384
.. TIP::
385385
Another clear reason to **never** use spaces or special characters in your
386386
mapfile's layer NAME parameter.
387-
387+
388388
.. image:: ../images/ogcapi-ms4w-collections-items-geojson.png
389389
:width: 400
390390
:class: no-scaled-link
391391

392392
.. TIP::
393393
See a live MapServer 8.0 `OGCAPI: Features` collection item (as GeoJSON) at
394394
https://demo.mapserver.org/cgi-bin/mapserv/localdemo/ogcapi/collections/lakes/items?f=json
395-
395+
396396
- you can access your OGC API collection items in HTML such as *ogcapi/collections/layername/items?f=html*
397397
such as::
398398

399399
http://127.0.0.1/cgi-bin/mapserv.exe/ + your mapfile alias + /ogcapi/collections/ + layername + /items?f=html
400-
400+
401401
or in the above example, it would be: ``http://127.0.0.1/cgi-bin/mapserv.exe/localdemo/ogcapi/collections/lakes/items?f=html``
402402

403403
.. image:: ../images/ogcapi-ms4w-collections-items-html.png
404404
:width: 400
405405
:class: no-scaled-link
406-
406+
407407
.. TIP::
408408
See a live MapServer 8.0 `OGCAPI: Features` collection item (in HTML) at
409409
https://demo.mapserver.org/cgi-bin/mapserv/localdemo/ogcapi/collections/lakes/items?f=html
@@ -415,13 +415,13 @@ API Document
415415
(JSON) or *ogcapi/api?f=html* (HTML) such as::
416416

417417
http://127.0.0.1/cgi-bin/mapserv.exe/ + your mapfile alias + /ogcapi/api?f=json
418-
418+
419419
or in the above example, it would be: ``http://127.0.0.1/cgi-bin/mapserv.exe/localdemo/ogcapi/api?f=json``
420-
420+
421421
.. image:: ../images/ogcapi-ms4w-api-json.png
422422
:width: 400
423423
:class: no-scaled-link
424-
424+
425425
.. TIP::
426426
See a live MapServer 8.0 `OGCAPI: Features` API document (in HTML) at
427427
https://demo.mapserver.org/cgi-bin/mapserv/localdemo/ogcapi/api?f=html
@@ -444,11 +444,70 @@ Web Object Metadata
444444
**ows_schemas_location**
445445

446446
.. versionadded:: 8.2.0
447-
447+
448448
- *Description:* (Optional) (Note the name *ows_schemas_location* because all
449449
OGC Web Services (OWS) use the same metadata) Root of the web tree where
450450
the family of OGC API JSON Schema files are located. This must be a valid URL
451451
where the actual .yaml files are located if you want your OpenAPI description
452452
to be valid. Default is *http://schemas.opengis.net*
453453

454+
.. index::
455+
triple: OGCAPI; METADATA; ows_schemas_location
456+
457+
**ows_extra_params**
458+
459+
.. versionadded:: 8.4.0
460+
461+
- *Description:* (Optional) The ``ows_extra_params`` (or ``oga_extra_params``) metadata entry allows you to append
462+
additional query parameters to all URLs generated by MapServer. This can be used, for example,
463+
to include authentication tokens such as JSON Web Tokens (JWT) in your API requests.
464+
465+
The value supports :ref:`Run-time Substitution <runsub>`, where tokens in the form
466+
``%TOKEN%``, are replaced with validated values from the query string or cookies.
467+
Parameters are validated against the rules in the :ref:`VALIDATION <validation>` block.
468+
``ows_extra_params`` can also be set at the ``LAYER`` ``METADATA`` level, for adding or overriding parameters at the collection-level.
469+
Example Mapfile:
470+
471+
.. code-block:: mapfile
472+
473+
WEB
474+
VALIDATION
475+
'token' '^[A-Za-z0-9\-_]+\.[A-Za-z0-9\-_]+\.[A-Za-z0-9\-_]+$'
476+
'user_id' '^[0-9]+$' # only allow integers
477+
'default_token' 'MISSING'
478+
'default_user_id' '-1'
479+
END
480+
METADATA
481+
"ows_extra_params" "token=%TOKEN%&user_id=%USER_ID%"
482+
483+
Example URL::
484+
485+
http://127.0.0.1/cgi-bin/mapserv.exe/localdemo/ogcapi?f=html&token=eyJ9.e30.SflKxw&user_id=938
486+
487+
Will return JSON containing the same parameters and values for all links:
488+
489+
.. code-block:: json
490+
491+
{
492+
"description": "This is a demo OGC API server.",
493+
"links": [
494+
{
495+
"href": "http://127.0.0.1/cgi-bin/mapserv.exe/localdemo/ogcapi?f=json&token=eyJ9.e30.SflKxw&user_id=938",
496+
497+
If a parameter is missing or invalid, it is replaced by the corresponding default value (e.g., ``MISSING`` for token, ``-1`` for user_id).
498+
Example URL::
499+
500+
http://127.0.0.1/cgi-bin/mapserv.exe/localdemo/ogcapi?f=html&token=@@@@@&user_id=a03kf-9
501+
502+
Will return:
503+
504+
.. code-block:: json
505+
506+
{
507+
"description": "This is a demo OGC API server.",
508+
"links": [
509+
{
510+
"href": "http://127.0.0.1/cgi-bin/mapserv.exe/localdemo/ogcapi?f=json&token=MISSING&user_id=-1",
454511

512+
The extra parameters are available in HTML templates for the OGC Features API as ``{{ template.extra_params }}``.
513+
The templates supplied in the MapServer repository append this value to all URLs by default.

0 commit comments

Comments
 (0)