This repository has been archived by the owner on Aug 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
config.js
154 lines (147 loc) · 4.18 KB
/
config.js
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
const AuthConfig = require('./auth')
const Action = AuthConfig.Action
const resources = AuthConfig.resources
const Reconfig = require('reconfig')
const defaultConfig = {
AuthConfig,
pgdb: {
user: 'postgres',
database: 'authorization',
password: 'postgres',
host: 'localhost',
port: 5432,
max: 10,
idleTimeoutMillis: 30000
},
logger: {
pino: {
level: 'info'
}
},
hooks: {
propagateErrors: false
},
authorization: {
defaultPageSize: 100,
organizations: {
defaultPolicies: {
orgAdmin: {
version: '1',
name: ':organizationId admin',
org_id: ':organizationId',
statements: {
Statement: [
{
Effect: 'Allow',
Action: [Action.ReadOrganization],
Resource: [resources.organizations({ organizationId: ':organizationId' })]
},
{
Effect: 'Allow',
Action: [Action.AllTeam],
Resource: [resources.teams({ organizationId: ':organizationId' })]
},
{
Effect: 'Allow',
Action: [Action.AllUser],
Resource: [resources.users({ organizationId: ':organizationId' })]
},
{
Effect: 'Allow',
Action: [Action.ListPolicies],
Resource: [resources.policies({ organizationId: ':organizationId' })]
},
{
Effect: 'Allow',
Action: [Action.ReadPolicy],
Resource: [resources.policies({ organizationId: ':organizationId' })]
},
{
Effect: 'Allow',
Action: [Action.ReadPolicyVariables],
Resource: [resources.policies({ organizationId: ':organizationId' })]
},
{
Effect: 'Allow',
Action: [Action.ListPolicyInstances],
Resource: [resources.policies({ organizationId: ':organizationId' })]
}
]
}
}
}
},
superUser: {
organization: {
id: 'ROOT',
name: 'SuperOrganization',
description: 'SuperUser Organization'
},
id: 'SuperUserId',
name: 'SuperUser',
defaultPolicy: {
version: '1',
name: 'SuperUser',
organizationId: ':organizationId',
statements: {
Statement: [{
Effect: 'Allow',
Action: ['*'],
Resource: ['*']
}]
}
}
},
teams: {
defaultPolicies: {
teamAdmin: {
version: '1',
name: 'Default Team Admin for :teamId',
org_id: ':organizationId',
statements: {
Statement: [
{
Effect: 'Allow',
Action: [
Action.ReadTeam,
Action.UpdateTeam,
Action.AddTeamMember,
Action.ReplaceTeamMember,
Action.ListTeamPolicies,
Action.RemoveTeamMember
],
Resource: [
resources.teams({ organizationId: ':organizationId', teamId: ':teamId' })
]
},
{
Effect: 'Allow',
Action: [
Action.AllUser
],
Resource: [
resources.users({ organizationId: ':organizationId', teamId: ':teamId' })
]
}
]
}
}
}
}
}
}
module.exports = (...amendments) => {
const reconfig = new Reconfig({}, { envPrefix: 'UDARU_SERVICE' })
amendments.unshift(defaultConfig)
amendments.filter((a) => (a)).forEach((amendment) => {
// support passing a reconfig object
if (amendment._config) {
reconfig.set(amendment._config)
} else {
reconfig.set(amendment)
}
})
// fix auth resource functions (since v3.3.0 reconfig drops functions and replaces them with an empty object)
reconfig._config.AuthConfig.resources = reconfig._rawConfig.AuthConfig.resources
return reconfig
}