© 2024 InterSystems Corporation, Cambridge, MA. All rights reserved.Privacy & TermsGuaranteeSection 508Contest Terms
YouTube video and header rule implementation
This is a ObjectScript Application to enforce authorization rules using XDATA into API methods.
Can be developed with Docker and VSCode,
can be deployed as ZPM module.
Clone/git pull the repo into any local directory e.g. like it is shown below (here I show all the examples related to this repository, but I assume you have your own derived from the template):
$ git clone git@github.com:yurimarx/iris-api-security-mediator.git
Open the terminal in this directory and run:
$ docker-compose up -d --build
zpm:USER>install iris-api-security-mediator
$ git clone git@github.com:yurimarx/iris-api-security-mediator.git
$ docker-compose up -d --build
/// Retreive all the records of dc.Sample.Person /// @security.and: roles: { PersonAdmin } ClassMethod GetAllPersons() As %Status {
#dim tSC As %Status = $$$OK ....
}
@security.and: roles: { PersonAdmin }
{
"verb": "GET",
"url": "/persons/all",
"application": "/crud/",
"method": "GetAllPersons",
"error": "_SYSTEM is not authorized for this request. User Roles Allowed is not in User Roles"
}
/// @security.and: header: { HTTP_ORGANIZATION = InterSystems }
ClassMethod GetInfo() As %Status
{
SET version = ..#Version
SET info = {
"version": (version),
"organization": (%request.GetCgiEnv("HTTP_ORGANIZATION"))
}
RETURN ..%ProcessResult($$$OK, info)
}
@security.and: header: { HTTP_ORGANIZATION = InterSystems }
{
"verb": "GET",
"url": "/",
"application": "/crud/",
"method": "GetInfo",
"header": "",
"error": "HTTP_ORGANIZATION = InterSystems is required in the request header"
}
Now, include into your Postman, or other REST Client the header key organization with value InterSystems and call http://localhost:52773/crud/ again. You have success!
Enjoy!
This app is on-line in the URL: http://ymservices.tech:52773/crud/