-
Notifications
You must be signed in to change notification settings - Fork 1
/
Utils.cls
71 lines (54 loc) · 2 KB
/
Utils.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Class sdf.Utils
{
/// Export a resultset to a XLS file
ClassMethod ResultSetToXls(resultSet As %SQL.StatementResult, fileName As %String) [ Language = python ]
{
from openpyxl import Workbook
from openpyxl.utils.dataframe import dataframe_to_rows
wb = Workbook()
ws = wb.active
import iris
pyResultSet = iris.cls('%SYS.Python.SQLResultSet')._New(resultSet)
df = pyResultSet.dataframe()
for r in dataframe_to_rows(df, index=True, header=True):
ws.append(r)
for cell in ws['A'] + ws[1]:
cell.style = 'Pandas'
wb.save(fileName)
}
/// Create an OAuth Authorization server configuration in IRIS
/// You can do the same thing in Management Portal:
/// System Administration > Security > OAuth 2.0 > Server
///
/// do ##class(sdf.Utils).CreateOAuth2Server()
ClassMethod CreateOAuth2Server() As %Status
{
set ns = $namespace
set $namespace = "%SYS"
set server = ##class(OAuth2.Server.Configuration).%New()
set server.Description = "AuthServer"
set endpoint = ##class(OAuth2.Endpoint).%New()
set endpoint.UseSSL = 1
set endpoint.Host = "webserver"
set endpoint.Prefix = "iris"
set server.IssuerEndpoint = endpoint
// supported grant types
set server.SupportedGrantTypes = "AC"
// use JWT tokens
set server.GenerateTokenClass = "%OAuth2.Server.JWT"
// support some specific scopes we can define
set scopes = ##class(%ArrayOfDataTypes).%New()
do scopes.SetAt("My own scope", "my/scope")
set server.SupportedScopes = scopes
// allow unsupported scopes (for testing different SMART on FHIR scopes)
set server.AllowUnsupportedScope = 1
// customize auth server as needed
set server.AuthenticateClass = "sdf.auth.Authenticate"
set server.ValidateUserClass = "sdf.auth.Validate"
set server.CustomizationNamespace = "SDF"
set server.CustomizationRoles = "%DB_IRISSYS,%Manager,%DB_SDF"
set server.SSLConfiguration = "ssl"
write server.Save()
set $namespace = ns
}
}