idnio 2.3.2b

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env ruby
2
+ require "json"
3
+ require "idnio/idnapi"
4
+ require "idnio/program"
5
+ require "idnio/markdown"
6
+
7
+ module Integrations
8
+
9
+ #
10
+ # Exports Integration configurations.
11
+ #
12
+ def self.export( directory )
13
+
14
+ response = IDNAPI.get( "#{$url}/cc/api/integration/listSimIntegrations", $token )
15
+
16
+ case response
17
+ when Net::HTTPSuccess
18
+
19
+ integrations = JSON.parse( response.body )
20
+
21
+ $log.info "\tDetected #{integrations.count} integrations."
22
+
23
+ integrations.each do |integration|
24
+
25
+ $log.info "\tIntegration: #{integration["name"]}"
26
+ Program.write_file( "#{directory}/integrations/", "Integration - #{integration["name"]}.json", JSON.pretty_generate( integration ) )
27
+
28
+ end
29
+
30
+ else
31
+ $log.error "\tError: Unable to fetch integrations."
32
+ end # case response
33
+
34
+ end
35
+
36
+ def self.import( directory )
37
+
38
+ # Read from the file system to determine how many integrations we have.
39
+ integrations = Program.read_directory( "#{directory}/integrations" )
40
+ $log.info "\tDetected #{integrations.length} integrations."
41
+
42
+ # Iterate through each transform.
43
+ integrations.each do |integration|
44
+
45
+ # Get the integration JSON.
46
+ template_integration = JSON.parse( integration )
47
+
48
+ $log.info "\tIntegration: #{integration["name"]}"
49
+
50
+ existing_integration = Integrations.get_by_name( integration["name"] )
51
+
52
+ # If we don't have an existing integration, lets create one.
53
+ if existing_integration.nil?
54
+
55
+ # Remove any ID since this isn't used in the creation.
56
+ template_integration['id'] = nil
57
+
58
+ # Remove the source references, since we can't look these up any longer.
59
+ template_integration['sources'] = []
60
+ $log.warn "\t\tSources could not be resolved and set. You may need to configure these when complete."
61
+
62
+ # Resolve the cluster settings for this tenant.
63
+ cluster_ref = ReferenceResolver.get_default_cluster_ref
64
+ unless cluster_ref['id'].nil?
65
+ template_integration['cluster'] = cluster_ref['id']
66
+ $log.warn "\t\tUsing default Virtual Appliance cluster."
67
+ else
68
+ template_integration['cluster'] = nil
69
+ $log.warn "\t\tSources could not be resolved and set. You may need to configure these when complete."
70
+ end
71
+
72
+ IDNAPI.post_json( "#{$url}/cc/api/integration/createSimIntegration", $token, template_transform )
73
+
74
+ # If we don't have an existing integration, lets update the one we have.
75
+ else
76
+
77
+ template_integration['id'] = existing_integration['existing_integration']
78
+ template_integration['sources'] = existing_integration['sources']
79
+ template_integration['cluster'] = existing_integration['cluster']
80
+
81
+ IDNAPI.post_json( "#{$url}/cc/api/integration/updateSimIntegration", $token, template_transform )
82
+
83
+ end
84
+
85
+ end
86
+ end
87
+
88
+ #
89
+ # Documents Integration configurations.
90
+ #
91
+ def self.doc
92
+
93
+ response = IDNAPI.get( "#{$url}/cc/api/integration/listSimIntegrations", $token )
94
+
95
+ case response
96
+ when Net::HTTPSuccess
97
+
98
+ integrations = JSON.parse( response.body )
99
+
100
+ Markdown.h2 "Integrations"
101
+
102
+ $log.info "\tDetected #{integrations.count} integrations."
103
+
104
+ integrations.each do |integration|
105
+
106
+ $log.info "\tIntegration: #{integration["name"]}"
107
+
108
+ Markdown.h3 "#{integration["name"]}"
109
+ Markdown.text "- **Name** - #{integration["name"]}\n"
110
+ Markdown.text "- **Type** - #{integration["type"]}\n"
111
+ Markdown.text "- **Description** - #{integration["description"]}\n"
112
+ Markdown.text "- **Cluster** - #{integration["cluster"]}\n"
113
+
114
+ Markdown.text( "- **Sources**\n" )
115
+
116
+ integration["sources"].each do |source|
117
+ Markdown.text( "\t- #{source}\n" )
118
+ end
119
+
120
+ Markdown.text( "- **Attributes**\n" )
121
+
122
+ integration["attributes"].each do |key,value|
123
+ Markdown.text( "\t- **#{key}** - #{value}\n" )
124
+ end
125
+
126
+ Markdown.text( "- **Status Map**\n" )
127
+
128
+ Markdown.text "| Integration Status | IdentityNow Status |\n"
129
+ Markdown.text "|--------------------|--------------------|\n"
130
+ integration["statusMap"].each do |key,value|
131
+ Markdown.text( "| #{key} | #{value} |\n" )
132
+ end
133
+
134
+ Markdown.text( "- **Request**\n" )
135
+
136
+ integration["request"].each do |key,value|
137
+ Markdown.text( "\t- **#{key}** - `#{value}`\n" )
138
+ end
139
+
140
+ end
141
+
142
+ else
143
+ $log.error "\tError: Unable to fetch integrations."
144
+ end # case response
145
+
146
+ Markdown.write
147
+
148
+ end # def self.doc
149
+ end
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+ require "json"
3
+ require "idnio/idnapi"
4
+ require "idnio/program"
5
+ require "idnio/markdown"
6
+
7
+ module LifecycleStates
8
+
9
+ #
10
+ # Exports Lifeycle State configurations.
11
+ #
12
+ def self.export( directory )
13
+
14
+ response = IDNAPI.get( "#{$url}/cc/api/profile/list", $token )
15
+
16
+ unless response.nil?
17
+
18
+ identityProfiles = JSON.parse( response.body )
19
+
20
+ identityProfiles.each do |identityProfile|
21
+
22
+ response = IDNAPI.get( "#{$url}/cc/api/profile/get/#{identityProfile["id"]}", $token )
23
+
24
+ unless response.nil?
25
+
26
+ JSON.parse( response.body )["configuredStates"].each do |lifecycleState|
27
+
28
+ response = IDNAPI.get( "#{$url}/cc/api/lifecycleState/get/#{lifecycleState["externalId"]}", $token )
29
+
30
+ lifecycleState = JSON.parse( response.body )
31
+
32
+ $log.info "\tLifecycle State: #{identityProfile["name"]} - #{lifecycleState["name"]}"
33
+
34
+ Program.write_file( "#{directory}/lifecycle-states/", "Lifecycle States - #{identityProfile["name"]} - #{lifecycleState["name"]}.json", JSON.pretty_generate( lifecycleState ) )
35
+
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ #
43
+ # Imports Lifeycle State configurations.
44
+ #
45
+ def self.import( directory )
46
+ $log.warn "\tImport for object type lifecycle-states is not supported at this time."
47
+ end
48
+
49
+ #
50
+ # Documents Lifecycle State configurations.
51
+ #
52
+ def self.doc
53
+ Markdown.h2( "Lifecycle States" )
54
+
55
+ response = IDNAPI.get( "#{$url}/cc/api/profile/list", $token )
56
+
57
+ unless response.nil?
58
+
59
+ identity_profiles = JSON.parse( response.body )
60
+
61
+ identity_profiles.each do |identity_profile|
62
+
63
+ response = IDNAPI.get( "#{$url}/cc/api/profile/get/#{identity_profile["id"]}", $token )
64
+
65
+ unless response.nil?
66
+
67
+ JSON.parse( response.body )["configuredStates"].each do |lifecycle_state|
68
+
69
+ response = IDNAPI.get( "#{$url}/cc/api/lifecycleState/get/#{lifecycle_state["externalId"]}", $token )
70
+
71
+ lifecycle_state = JSON.parse( response.body )
72
+
73
+ $log.info "\tLifecycle State: #{identity_profile["name"]} - #{lifecycle_state["displayName"]}"
74
+ Markdown.h3( "#{identity_profile["name"]} - #{lifecycle_state["name"]}" )
75
+ Markdown.text( "- **Display Name** - #{lifecycle_state["displayName"]}\n" )
76
+ Markdown.text( "- **Name** - #{lifecycle_state["name"]}\n" )
77
+ Markdown.text( "- **Enabled** - #{lifecycle_state["enabled"]}\n" )
78
+ Markdown.text( "- **Description** - #{lifecycle_state["description"]}\n" )
79
+ end
80
+ end
81
+ end
82
+ end
83
+ Markdown.write
84
+ end
85
+
86
+ end
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env ruby
2
+ require "json"
3
+ require "idnio/idnapi"
4
+ require "idnio/program"
5
+ require "idnio/markdown"
6
+
7
+ module PasswordPolicies
8
+
9
+ def self.query( query )
10
+ response = IDNAPI.get( "#{$url}/cc/api/passwordPolicy/list", $token )
11
+ unless response.nil?
12
+ policies = JSON.parse( response.body )
13
+
14
+ policies.each do |policy|
15
+ if(policy["name"] == query)
16
+ return policy
17
+ end
18
+ end
19
+ end
20
+ return nil
21
+ end
22
+
23
+ def self.create( params )
24
+ create_params = {
25
+ "name" => params["name"],
26
+ "maxLength" => params["maxLength"],
27
+ "minLength" => params["minLength"],
28
+ "minAlpha" => params["minAlpha"],
29
+ "minUpper" => params["minUpper"],
30
+ "minLower" => params["minLower"],
31
+ "minNumeric" => params["minNumeric"],
32
+ "minSpecial" => params["minSpecial"],
33
+ "minCharacterTypes" => params["minCharacterTypes"],
34
+ "maxRepeatedChars" => params["maxRepeatedChars"],
35
+ "useHistory" => params["useHistory"],
36
+ "useAccountAttributes" => params["useAccountAttributes"],
37
+ "useIdentityAttributes" => params["useIdentityAttributes"],
38
+ "validateAgainstAccountName" => params["validateAgainstAccountName"],
39
+ "validateAgainstAccountId" => params["validateAgainstAccountId"],
40
+ "useDictionary" => params["useDictionary"],
41
+ "enablePasswdExpiration" => params["enablePasswdExpiration"],
42
+ "requireStrongAuthn" => params["requireStrongAuthn"],
43
+ "requireStrongAuthOffNetwork" => params["requireStrongAuthOffNetwork"],
44
+ "requireStrongAuthUntrustedGeographies" => params["requireStrongAuthUntrustedGeographies"]
45
+ }
46
+ response = IDNAPI.post_form( "#{$url}/cc/api/passwordPolicy/create", $token, create_params )
47
+ return response
48
+ end
49
+
50
+ def self.update( params, id )
51
+ update_params = {
52
+ "name" => params["name"],
53
+ "maxLength" => params["maxLength"],
54
+ "minLength" => params["minLength"],
55
+ "minAlpha" => params["minAlpha"],
56
+ "minUpper" => params["minUpper"],
57
+ "minLower" => params["minLower"],
58
+ "minNumeric" => params["minNumeric"],
59
+ "minSpecial" => params["minSpecial"],
60
+ "minCharacterTypes" => params["minCharacterTypes"],
61
+ "maxRepeatedChars" => params["maxRepeatedChars"],
62
+ "useHistory" => params["useHistory"],
63
+ "useAccountAttributes" => params["useAccountAttributes"],
64
+ "useIdentityAttributes" => params["useIdentityAttributes"],
65
+ "validateAgainstAccountName" => params["validateAgainstAccountName"],
66
+ "validateAgainstAccountId" => params["validateAgainstAccountId"],
67
+ "useDictionary" => params["useDictionary"],
68
+ "enablePasswdExpiration" => params["enablePasswdExpiration"],
69
+ "requireStrongAuthn" => params["requireStrongAuthn"],
70
+ "requireStrongAuthOffNetwork" => params["requireStrongAuthOffNetwork"],
71
+ "requireStrongAuthUntrustedGeographies" => params["requireStrongAuthUntrustedGeographies"]
72
+ }
73
+ response = IDNAPI.post_form( "#{$url}/cc/api/passwordPolicy/set/#{id}", $token, update_params )
74
+ return response
75
+ end
76
+
77
+ #
78
+ # Exports Password Policy configurations.
79
+ #
80
+ def self.export( directory )
81
+
82
+ response = IDNAPI.get( "#{$url}/cc/api/passwordPolicy/list", $token )
83
+ unless response.nil?
84
+ policies = JSON.parse( response.body )
85
+ $log.info "\tDetected #{policies.count} policies."
86
+ policies.each do |policy|
87
+ $log.debug "\tPolicy: #{policy["name"]}"
88
+ Program.write_file( "#{directory}/password-policies/", "Password Policy - #{policy["name"]}.json", JSON.pretty_generate( policy ) )
89
+ end
90
+ end
91
+ end
92
+
93
+ #
94
+ # Import Password Policies configurations.
95
+ #
96
+ def self.import( directory )
97
+ $log.warn "\tImport for object type password-policies is not supported at this time."
98
+ end
99
+
100
+ #
101
+ # Documents Password Policies configurations.
102
+ #
103
+ def self.doc
104
+ $log.warn "\tDocumentation for object type password-policies is not supported at this time."
105
+ end
106
+
107
+ end
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env ruby
2
+ require "json"
3
+ require "idnio/idnapi"
4
+ require "idnio/program"
5
+ require "idnio/markdown"
6
+ require "objects/sources"
7
+
8
+ module PasswordSyncGroups
9
+
10
+ def self.getPolicyId( query )
11
+ response = IDNAPI.get( "#{$url}/cc/api/passwordPolicy/list", $token )
12
+ unless response.nil?
13
+ policies = JSON.parse( response.body )
14
+
15
+ policies.each do |policy|
16
+ if(policy["name"] == query)
17
+ return policy["id"]
18
+ end
19
+ end
20
+ end
21
+ return nil
22
+ end
23
+
24
+ def self.getPolicyName( query )
25
+ response = IDNAPI.get( "#{$url}/cc/api/passwordPolicy/get/#{query}", $token )
26
+ unless response.nil?
27
+ policy = JSON.parse( response.body )
28
+
29
+ return policy["name"]
30
+ end
31
+ return nil
32
+ end
33
+
34
+ def self.query( query )
35
+ response = IDNAPI.get( "#{$url}/cc/api/passwordSyncGroup/list", $token )
36
+ unless response.nil?
37
+ groups = JSON.parse( response.body )
38
+ groups.each do |group|
39
+ if(group["name"] == query)
40
+ return group
41
+ end
42
+ end
43
+ end
44
+ return nil
45
+ end
46
+
47
+ def self.create( param )
48
+ create_params = {
49
+ "name" => param["name"],
50
+ "passwordPolicyId" => param["passwordPolicyId"],
51
+ "sources" => param["sources"]
52
+ }
53
+ response = IDNAPI.post_json( "#{$url}/cc/api/passwordSyncGroup/create", $token, create_params )
54
+ return response
55
+ end
56
+
57
+ def self.update( param )
58
+ update_params = {
59
+ "id" => param["id"],
60
+ "name" => param["name"],
61
+ "passwordPolicyId" => param["passwordPolicyId"],
62
+ "sources" => param["sources"]
63
+ }
64
+ response = IDNAPI.post_json( "#{$url}/cc/api/passwordSyncGroup/set/#{param["id"]}", $token, update_params )
65
+ return response
66
+ end
67
+
68
+ #
69
+ # Exports Password Sync Group configurations.
70
+ #
71
+ def self.export( directory )
72
+
73
+ response = IDNAPI.get( "#{$url}/cc/api/passwordSyncGroup/list", $token )
74
+ unless response.nil?
75
+ groups = JSON.parse( response.body )
76
+ $log.info "\tDetected #{groups.count} sync groups."
77
+ groups.each do |group|
78
+ $log.debug "\tSync Group: #{group["name"]}"
79
+ policyName = PasswordSyncGroups.getPolicyName( group["passwordPolicyId"] )
80
+ group["passwordPolicyName"] = policyName
81
+ Program.write_file( "#{directory}/password-sync-groups/", "Password Sync Group - #{group["name"]}.json", group.to_json )
82
+ end
83
+ end
84
+ end
85
+
86
+ #
87
+ # Import Password Sync Groups configurations.
88
+ #
89
+ def self.import( directory )
90
+ $log.warn "\tImport for object type password-sync-groups is not supported at this time."
91
+ end
92
+
93
+ #
94
+ # Documents Password Sync Groups configurations.
95
+ #
96
+ def self.doc
97
+ $log.warn "\tDocumentation for object type password-sync-groups is not supported at this time."
98
+ end
99
+
100
+ end
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env ruby
2
+ require "json"
3
+ require "uri"
4
+ require "idnio/idnapi"
5
+ require "idnio/program"
6
+ require "idnio/markdown"
7
+
8
+ module PublicIdentitiesConfig
9
+
10
+ #
11
+ # Exports Public Identity Config
12
+ #
13
+ def self.export( directory )
14
+
15
+ response = IDNAPI.get( "#{$url}/beta/public-identities-config/", $token )
16
+
17
+ case response
18
+ when Net::HTTPSuccess
19
+ $log.info "\tRetreived configuration."
20
+ config = JSON.parse( response.body )
21
+ Program.write_file( "#{directory}/public-identities-config/", "public-identities-config.json", JSON.pretty_generate( config ) )
22
+ else
23
+ $log.error "\tUnable to retreive configuration."
24
+ end
25
+
26
+ end
27
+
28
+ #
29
+ # Imports Public Identity Config
30
+ #
31
+ def self.import( directory )
32
+
33
+ # Read from the file system to determine how many configs we have. We should really only have one.
34
+ configs = Program.read_directory( "#{directory}/public-identities-config/" )
35
+ $log.info "\tRetreived configuration."
36
+
37
+ # Iterate through each transform.
38
+ configs.each do |config|
39
+
40
+ $log.debug "\t\tImporting public identities config..."
41
+
42
+ response = IDNAPI.put_json( "#{$url}/beta/public-identities-config/", $token, JSON.parse( config ) )
43
+
44
+ case response
45
+ when Net::HTTPSuccess
46
+ $log.info "\tUpdated public identities config."
47
+ else
48
+ $log.error "\tUnable to import public identities config."
49
+ end
50
+ end
51
+ end
52
+
53
+ #
54
+ # Documents Public Identity Config
55
+ #
56
+ def self.doc
57
+
58
+ Markdown.h2( "Public Identity Config" )
59
+
60
+ response = IDNAPI.get( "#{$url}/beta/public-identities-config/", $token )
61
+ case response
62
+ when Net::HTTPSuccess
63
+ $log.info "\tRetreived configuration."
64
+
65
+ config = JSON.parse( response.body )
66
+
67
+ Markdown.text "Attributes:\n"
68
+ config['attributes'].each do |attribute|
69
+ Markdown.text "- #{attribute['name']}\n"
70
+ end
71
+
72
+ else
73
+ $log.error "\tUnable to retreive configuration."
74
+ end
75
+
76
+ Markdown.write
77
+ end
78
+ end