Skip to content

Commit 04b0904

Browse files
Alberto FuentesAlberto Fuentes
Alberto Fuentes
authored and
Alberto Fuentes
committed
initial commit
0 parents  commit 04b0904

21 files changed

+2392
-0
lines changed

.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ISC_IAM_IMAGE=intersystems/iam:0.34-1-1
2+
ISC_IRIS_URL=http://IAM:1234@irisA:52773/api/iam/license

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.sh text eol=lf
2+
*.cls text eol=lf
3+
*.mac text eol=lf
4+
*.int text eol=lf
5+
Dockerfil* text eol=lf

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
iris.key
3+
IAM/**

.vscode/settings.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"objectscript.export.folder": "src",
3+
"objectscript.conn": {
4+
"active": false,
5+
"username": "superuser",
6+
"password": "SYS",
7+
"docker-compose": {
8+
"service": "irisA"
9+
},
10+
"ns": "WEBINAR",
11+
"port": 52773,
12+
"host": "localhost"
13+
}
14+
}

Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM containers.intersystems.com/intersystems/iris:2020.2.0.211.0
2+
3+
USER root
4+
5+
COPY --chown=$ISC_PACKAGE_MGRUSER:$ISC_PACKAGE_IRISGROUP irissession.sh /
6+
RUN chmod +x /irissession.sh
7+
8+
# copy source code
9+
RUN mkdir -p /opt/webinar/install
10+
COPY install /opt/webinar/install
11+
RUN mkdir -p /opt/webinar/src
12+
COPY src /opt/webinar/src/
13+
14+
# change permissions to IRIS user
15+
RUN chown -R ${ISC_PACKAGE_MGRUSER}:${ISC_PACKAGE_IRISGROUP} /opt/webinar
16+
17+
USER irisowner
18+
19+
# download zpm package manager
20+
RUN mkdir -p /tmp/deps \
21+
&& cd /tmp/deps \
22+
&& wget -q https://pm.community.intersystems.com/packages/zpm/latest/installer -O zpm.xml
23+
24+
25+
SHELL ["/irissession.sh"]
26+
27+
RUN \
28+
zn "USER" \
29+
# load & compile source code
30+
do $system.OBJ.Load("/opt/webinar/src/Webinar/Installer.cls", "ck") \
31+
do ##class(Webinar.Installer).Run() \
32+
# install zpm & webterminal
33+
zn "WEBINAR" \
34+
Do $system.OBJ.Load("/tmp/deps/zpm.xml", "ck") \
35+
zpm "install webterminal" \
36+
set sc = 1
37+
38+
# bringing the standard shell back
39+
SHELL ["/bin/bash", "-c"]

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Workshop: REST and InterSystems API Manager
2+
This repository contains the materials and some examples you can use to learn the basic concepts of REST and IAM.
3+
4+
You can find more in-depth information in https://learning.intersystems.com.
5+
6+
# What do you need to install?
7+
* [Git](https://git-scm.com/downloads)
8+
* [Docker](https://www.docker.com/products/docker-desktop) (if you are using Windows, make sure you set your Docker installation to use "Linux containers").
9+
* [Docker Compose](https://docs.docker.com/compose/install/)
10+
* [Visual Studio Code](https://code.visualstudio.com/download) + [InterSystems ObjectScript VSCode Extension](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript)
11+
* [Postman](https://www.getpostman.com/downloads/)
12+
13+
# Setup
14+
Build the image we will use during the workshop:
15+
16+
```console
17+
$ git clone https://github.com/intersystems-ib/workshop-rest-iam
18+
$ cd workshop-rest-iam
19+
$ docker-compose build
20+
```
21+
22+
# Examples
23+
24+
## (a). TODO
25+
Container registry
26+
IAM license
27+
IAM install
28+
start

docker-compose.yml

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
version: '3.2'
2+
3+
services:
4+
5+
# ==================
6+
# InterSystems IRIS
7+
# ==================
8+
9+
# irisA instance
10+
irisA:
11+
build:
12+
context: .
13+
container_name: irisA
14+
image: workshop-rest-iam:latest
15+
ports:
16+
- "52773:52773"
17+
volumes:
18+
- ./iris.key:/usr/irissys/mgr/iris.key
19+
- ./shared:/shared
20+
21+
# irisB instance
22+
irisB:
23+
image: workshop-rest-iam:latest
24+
container_name: irisB
25+
ports:
26+
- "52774:52773"
27+
volumes:
28+
- ./iris.key:/usr/irissys/mgr/iris.key
29+
- ./shared:/shared
30+
31+
# irisC instance
32+
irisC:
33+
image: workshop-rest-iam:latest
34+
container_name: irisC
35+
ports:
36+
- "52775:52773"
37+
volumes:
38+
- ./iris.key:/usr/irissys/mgr/iris.key
39+
- ./shared:/shared
40+
41+
42+
# ===================================
43+
# IAM - InterSystems API Manager 0.34
44+
# ===================================
45+
iam-migrations:
46+
image: "${ISC_IAM_IMAGE}"
47+
command: kong migrations up
48+
depends_on:
49+
- db
50+
environment:
51+
KONG_DATABASE: postgres
52+
KONG_PG_DATABASE: ${KONG_PG_DATABASE:-iam}
53+
KONG_PG_HOST: db
54+
KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-iam}
55+
KONG_PG_USER: ${KONG_PG_USER:-iam}
56+
KONG_CASSANDRA_CONTACT_POINTS: db
57+
ISC_IRIS_URL: "${ISC_IRIS_URL}"
58+
restart: on-failure
59+
links:
60+
- db:db
61+
iam:
62+
image: "${ISC_IAM_IMAGE}"
63+
depends_on:
64+
- db
65+
- irisA
66+
environment:
67+
KONG_ADMIN_ACCESS_LOG: /dev/stdout
68+
KONG_ADMIN_ERROR_LOG: /dev/stderr
69+
KONG_ADMIN_LISTEN: '0.0.0.0:8001'
70+
KONG_ANONYMOUS_REPORTS: 'off'
71+
KONG_CASSANDRA_CONTACT_POINTS: db
72+
KONG_DATABASE: postgres
73+
KONG_PG_DATABASE: ${KONG_PG_DATABASE:-iam}
74+
KONG_PG_HOST: db
75+
KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-iam}
76+
KONG_PG_USER: ${KONG_PG_USER:-iam}
77+
KONG_PROXY_ACCESS_LOG: /dev/stdout
78+
KONG_PROXY_ERROR_LOG: /dev/stderr
79+
KONG_PORTAL: 'on'
80+
KONG_PORTAL_GUI_PROTOCOL: http
81+
KONG_PORTAL_GUI_HOST: '127.0.0.1:8003'
82+
ISC_IRIS_URL: "${ISC_IRIS_URL}"
83+
links:
84+
- db:db
85+
ports:
86+
- target: 8000
87+
published: 8000
88+
protocol: tcp
89+
- target: 8001
90+
published: 8001
91+
protocol: tcp
92+
- target: 8002
93+
published: 8002
94+
protocol: tcp
95+
- target: 8003
96+
published: 8003
97+
protocol: tcp
98+
- target: 8004
99+
published: 8004
100+
protocol: tcp
101+
- target: 8443
102+
published: 8443
103+
protocol: tcp
104+
- target: 8444
105+
published: 8444
106+
protocol: tcp
107+
- target: 8445
108+
published: 8445
109+
protocol: tcp
110+
restart: on-failure
111+
db:
112+
image: postgres:latest
113+
environment:
114+
POSTGRES_DB: ${KONG_PG_DATABASE:-iam}
115+
POSTGRES_PASSWORD: ${KONG_PG_PASSWORD:-iam}
116+
POSTGRES_USER: ${KONG_PG_USER:-iam}
117+
volumes:
118+
- 'pgdata:/var/lib/postgresql/data'
119+
healthcheck:
120+
test: ["CMD", "pg_isready", "-U", "${KONG_PG_USER:-iam}"]
121+
interval: 30s
122+
timeout: 30s
123+
retries: 3
124+
restart: on-failure
125+
stdin_open: true
126+
tty: true
127+
volumes:
128+
pgdata:

install/Webinar-Role.xml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<RolesExport>
3+
<Roles>
4+
<Name>Webinar</Name>
5+
<Resources>
6+
<Resource>
7+
<Name>%DB_%DEFAULT</Name>
8+
<Permission>3</Permission>
9+
</Resource>
10+
<Resource>
11+
<Name>%DB_USER</Name>
12+
<Permission>3</Permission>
13+
</Resource>
14+
</Resources>
15+
</Roles>
16+
<Roles>
17+
<Name>Webinar</Name>
18+
<Resources>
19+
<Resource>
20+
<Name>%DB_%DEFAULT</Name>
21+
<Permission>3</Permission>
22+
</Resource>
23+
<Resource>
24+
<Name>%DB_USER</Name>
25+
<Permission>3</Permission>
26+
</Resource>
27+
</Resources>
28+
</Roles>
29+
<SQLPrivileges>
30+
<Namespace>WEBINAR</Namespace>
31+
<SQLObject>1,Webinar_Data.Player</SQLObject>
32+
<Privilege>d</Privilege>
33+
<Grantee>Webinar</Grantee>
34+
<Grantor>SuperUser</Grantor>
35+
<Grantable>0</Grantable>
36+
</SQLPrivileges>
37+
<SQLPrivileges>
38+
<Namespace>WEBINAR</Namespace>
39+
<SQLObject>1,Webinar_Data.Player</SQLObject>
40+
<Privilege>i</Privilege>
41+
<Grantee>Webinar</Grantee>
42+
<Grantor>SuperUser</Grantor>
43+
<Grantable>0</Grantable>
44+
</SQLPrivileges>
45+
<SQLPrivileges>
46+
<Namespace>WEBINAR</Namespace>
47+
<SQLObject>1,Webinar_Data.Player</SQLObject>
48+
<Privilege>s</Privilege>
49+
<Grantee>Webinar</Grantee>
50+
<Grantor>SuperUser</Grantor>
51+
<Grantable>0</Grantable>
52+
</SQLPrivileges>
53+
<SQLPrivileges>
54+
<Namespace>WEBINAR</Namespace>
55+
<SQLObject>1,Webinar_Data.Player</SQLObject>
56+
<Privilege>u</Privilege>
57+
<Grantee>Webinar</Grantee>
58+
<Grantor>SuperUser</Grantor>
59+
<Grantable>0</Grantable>
60+
</SQLPrivileges>
61+
<SQLPrivileges>
62+
<Namespace>WEBINAR</Namespace>
63+
<SQLObject>1,Webinar_Data.Team</SQLObject>
64+
<Privilege>d</Privilege>
65+
<Grantee>Webinar</Grantee>
66+
<Grantor>SuperUser</Grantor>
67+
<Grantable>0</Grantable>
68+
</SQLPrivileges>
69+
<SQLPrivileges>
70+
<Namespace>WEBINAR</Namespace>
71+
<SQLObject>1,Webinar_Data.Team</SQLObject>
72+
<Privilege>i</Privilege>
73+
<Grantee>Webinar</Grantee>
74+
<Grantor>SuperUser</Grantor>
75+
<Grantable>0</Grantable>
76+
</SQLPrivileges>
77+
<SQLPrivileges>
78+
<Namespace>WEBINAR</Namespace>
79+
<SQLObject>1,Webinar_Data.Team</SQLObject>
80+
<Privilege>s</Privilege>
81+
<Grantee>Webinar</Grantee>
82+
<Grantor>SuperUser</Grantor>
83+
<Grantable>0</Grantable>
84+
</SQLPrivileges>
85+
<SQLPrivileges>
86+
<Namespace>WEBINAR</Namespace>
87+
<SQLObject>1,Webinar_Data.Team</SQLObject>
88+
<Privilege>u</Privilege>
89+
<Grantee>Webinar</Grantee>
90+
<Grantor>SuperUser</Grantor>
91+
<Grantable>0</Grantable>
92+
</SQLPrivileges>
93+
</RolesExport>

install/user-iam.xml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<UsersExport>
3+
<Users>
4+
<AccountNeverExpires>true</AccountNeverExpires>
5+
<AutheEnabled>0</AutheEnabled>
6+
<ChangePassword>false</ChangePassword>
7+
<CreateDateTime>65559,49486.273898</CreateDateTime>
8+
<Enabled>true</Enabled>
9+
<ExpirationDate>1840-12-31</ExpirationDate>
10+
<Flags>1</Flags>
11+
<FullName>User for /api/iam Web Application</FullName>
12+
<HOTPKey>0DAcwOp5xQSFDlpul+AeYMhpcF8=</HOTPKey>
13+
<HOTPKeyGenerate>false</HOTPKeyGenerate>
14+
<HOTPKeyDisplay>false</HOTPKeyDisplay>
15+
<LastModifiedDateTime>65623,37019.832752</LastModifiedDateTime>
16+
<LastModifiedInfo>
17+
Enabled modified:
18+
New value: Yes
19+
Old value: No
20+
21+
Password modified:
22+
New value: *****
23+
Old value: *****
24+
</LastModifiedInfo>
25+
<LastModifiedUsername>SuperUser</LastModifiedUsername>
26+
<Name>IAM</Name>
27+
<Password>4BnynQwFCJFECG9ZqINnT3lC/vY=</Password>
28+
<PasswordNeverExpires>true</PasswordNeverExpires>
29+
<PasswordChangedDateTime>65623,37019.832609</PasswordChangedDateTime>
30+
<Roles>
31+
<RolesItem>%IAM_API</RolesItem>
32+
</Roles>
33+
<Salt>FT33QuW0h9c=</Salt>
34+
</Users>
35+
</UsersExport>

install/webapp-iam.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApplicationsExport>
3+
<Applications>
4+
<AutheEnabled>32</AutheEnabled>
5+
<AutoCompile>false</AutoCompile>
6+
<CookiePath>/api/iam/</CookiePath>
7+
<CSPZENEnabled>true</CSPZENEnabled>
8+
<CSRFToken>false</CSRFToken>
9+
<DeepSeeEnabled>false</DeepSeeEnabled>
10+
<Description>IAM REST Apis</Description>
11+
<DispatchClass>%Api.IAM.v1.disp</DispatchClass>
12+
<Enabled>true</Enabled>
13+
<HyperEvent>0</HyperEvent>
14+
<iKnowEnabled>false</iKnowEnabled>
15+
<InbndWebServicesEnabled>false</InbndWebServicesEnabled>
16+
<IsNameSpaceDefault>false</IsNameSpaceDefault>
17+
<LockCSPName>true</LockCSPName>
18+
<Name>/api/iam</Name>
19+
<NameSpace>%SYS</NameSpace>
20+
<Recurse>true</Recurse>
21+
<Resource>%IAM</Resource>
22+
<ServeFiles>1</ServeFiles>
23+
<ServeFilesTimeout>3600</ServeFilesTimeout>
24+
<Timeout>3600</Timeout>
25+
<TwoFactorEnabled>false</TwoFactorEnabled>
26+
<Type>2</Type>
27+
<UseCookies>2</UseCookies>
28+
</Applications>
29+
</ApplicationsExport>

0 commit comments

Comments
 (0)