freeipa_easy 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d80918ec28d3a554d3a37eafb750a738d18d15e5
4
+ data.tar.gz: ced0a6fa318ed92d17012aa680d57f1ccde114eb
5
+ SHA512:
6
+ metadata.gz: f77f93ecb593a717c589738dd8f3087c75c9c0782e961f455acd137188c4c12fba3dc54062063bd6367b96f168718d9709c07f29885a0119a7e44662f54502da
7
+ data.tar.gz: 2fa32235fdb525753364c64754bf9ab33990324c9813a866547ef18fa06ad74fcf65f7414055fa478b3c68b2aaa30c1f7e7b18c9ec7d30d8142b6244039c08c1
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in freeipa_easy.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 cloudforms-1ba
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # FreeipaEasy
2
+
3
+ Welcome to Freeipa Easy!
4
+
5
+ You can use this gem to easy connect to free ipa system and wok with users in this system/
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'freeipa_easy'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install freeipa_easy
22
+
23
+ ## Usage
24
+
25
+ I will write examples later
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/arnikasky/freeipa_easy.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
3
+ task :console do
4
+ exec "irb -r freeipa_easy -I ./lib"
5
+ end
6
+ task :test do
7
+ exec "ruby ./test/*"
8
+ end
9
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "freeipa_easy"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'freeipa_easy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "freeipa_easy"
8
+ spec.version = FreeipaEasy::VERSION
9
+ spec.authors = ["Hanna Novikava"]
10
+ spec.email = ["arnikasky@gmail.com"]
11
+
12
+ spec.summary = %q{Help to work with users in freeipa}
13
+ spec.description = %q{It's a small library, which will help with users and may be with other things in freeipa}
14
+ spec.homepage = "https://github.com/arnikasky/freeipa_easy"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_dependency "rest-client", "~> 2.0.0"
36
+ spec.add_dependency "test-unit-full", "~> 0.0.5"
37
+ end
Binary file
@@ -0,0 +1,150 @@
1
+ module FreeipaEasy
2
+ require 'rest-client'
3
+ require 'json'
4
+ class User
5
+ attr_reader :url, :user, :password, :cookies
6
+ def initialize(url, user, password)
7
+ @url = url
8
+ @user = user
9
+ @password = password
10
+ end
11
+
12
+ def authentication_password
13
+ begin
14
+ login_freeipa = RestClient::Request.execute(method: :post, url: url+'/ipa/session/login_password', :verify_ssl => false, :payload => "user=#{@user}&password=#{@password}",
15
+ :headers => {:Referer => url+'/ipa'})
16
+ @cookies = login_freeipa.cookies
17
+ rescue Exception => e
18
+ puts "#{e.class}" +": " + "#{e.message}"
19
+ end
20
+ true
21
+ end
22
+
23
+ def add_user(first_name, last_name, login, mail, password)
24
+ begin
25
+ cn = first_name + " " + last_name
26
+ payload = {"method":"user_add",
27
+ "params":[[login],
28
+ {"cn": cn, "mail": mail, "givenname": first_name, "sn": last_name, "userpassword": password}],
29
+ "id":0}
30
+ data_json = RestClient::Request.execute(method: :post,
31
+ url: @url +'/ipa/session/json',
32
+ :verify_ssl => false,
33
+ :cookies => @cookies,
34
+ :payload => payload.to_json,
35
+ :headers => {:content_type => :json, :accept =>:json,
36
+ :Referer => url + '/ipa'})
37
+ data = JSON.parse(data_json)
38
+ rescue Exception => e
39
+ puts "#{e.class}" +": " + "#{e.message}"
40
+ end
41
+ data["error"]
42
+ end
43
+
44
+ def delete_user(login)
45
+ begin
46
+ payload = {"id": 0, "method": "user_del", "params": [[[login]],{ }]}
47
+ data_json = RestClient::Request.execute(method: :post,
48
+ url: @url +'/ipa/session/json',
49
+ :verify_ssl => false,
50
+ :cookies => @cookies,
51
+ :payload => payload.to_json,
52
+ :headers => {:content_type => :json, :accept =>:json,
53
+ :Referer => url + '/ipa'})
54
+ data = JSON.parse(data_json)
55
+ rescue Exception => e
56
+ puts "#{e.class}" +": " + "#{e.message}"
57
+ end
58
+ data["error"]
59
+ end
60
+
61
+ def show_user(login)
62
+ begin
63
+ payload = {"id": 0, "method": "user_show", "params": [[login], {"all": false, "no_members": false,"raw": false,"rights": false}]}
64
+ data_json = RestClient::Request.execute(method: :post,
65
+ url: @url +'/ipa/session/json',
66
+ :verify_ssl => false,
67
+ :cookies => @cookies,
68
+ :payload => payload.to_json,
69
+ :headers => {:content_type => :json, :accept =>:json,
70
+ :Referer => url + '/ipa'})
71
+ data = JSON.parse(data_json)
72
+ rescue Exception => e
73
+ puts "#{e.class}" +": " + "#{e.message}"
74
+ end
75
+ data["error"]
76
+ end
77
+
78
+ def disable_user(login)
79
+ begin
80
+ payload = {"id": 0, "method": "user_disable", "params": [[login], {}]}
81
+ data_json = RestClient::Request.execute(method: :post,
82
+ url: @url +'/ipa/session/json',
83
+ :verify_ssl => false,
84
+ :cookies => @cookies,
85
+ :payload => payload.to_json,
86
+ :headers => {:content_type => :json, :accept =>:json,
87
+ :Referer => url + '/ipa'})
88
+ data = JSON.parse(data_json)
89
+ rescue Exception => e
90
+ puts "#{e.class}" +": " + "#{e.message}"
91
+ end
92
+ data["error"]
93
+ end
94
+
95
+ def unlock_user(login)
96
+ begin
97
+ payload = {"id": 0, "method": "user_unlock", "params": [[login], {}]}
98
+ data_json = RestClient::Request.execute(method: :post,
99
+ url: @url +'/ipa/session/json',
100
+ :verify_ssl => false,
101
+ :cookies => @cookies,
102
+ :payload => payload.to_json,
103
+ :headers => {:content_type => :json, :accept =>:json,
104
+ :Referer => url + '/ipa'})
105
+ data = JSON.parse(data_json)
106
+ rescue Exception => e
107
+ puts "#{e.class}" +": " + "#{e.message}"
108
+ end
109
+ data["error"]
110
+ end
111
+
112
+ def enable_user(login)
113
+ begin
114
+ payload = {"id": 0, "method": "user_enable", "params": [[login], {}]}
115
+ data_json = RestClient::Request.execute(method: :post,
116
+ url: @url +'/ipa/session/json',
117
+ :verify_ssl => false,
118
+ :cookies => @cookies,
119
+ :payload => payload.to_json,
120
+ :headers => {:content_type => :json, :accept =>:json,
121
+ :Referer => url + '/ipa'})
122
+ data = JSON.parse(data_json)
123
+ rescue Exception => e
124
+ puts "#{e.class}" +": " + "#{e.message}"
125
+ end
126
+ data["error"]
127
+ end
128
+
129
+ def modify_user(login,payload_options={})
130
+ begin
131
+ payload_options.merge!({"all": false, "no_members": false,"raw": false,"rights": false})
132
+ test = {"all": false, "no_members": false,"raw": false,"rights": false}
133
+ payload = {"id": 0, "method": "user_mod", "params": [[login], payload_options]}
134
+ data_json = RestClient::Request.execute(method: :post,
135
+ url: @url +'/ipa/session/json',
136
+ :verify_ssl => false,
137
+ :cookies => @cookies,
138
+ :payload => payload.to_json,
139
+ :headers => {:content_type => :json, :accept =>:json,
140
+ :Referer => url + '/ipa'})
141
+ data = JSON.parse(data_json)
142
+ rescue Exception => e
143
+ puts "#{e.class}" +": " + "#{e.message}"
144
+ end
145
+ data["error"]
146
+ end
147
+
148
+ end
149
+ end
150
+
@@ -0,0 +1,3 @@
1
+ module FreeipaEasy
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "freeipa_easy/version"
2
+ require "freeipa_easy/user"
3
+
4
+ module FreeipaEasy
5
+ # Your code goes here...
6
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: freeipa_easy
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Hanna Novikava
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit-full
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.5
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.5
69
+ description: It's a small library, which will help with users and may be with other
70
+ things in freeipa
71
+ email:
72
+ - arnikasky@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - freeipa_easy.gemspec
85
+ - lib/freeipa_easy.rb
86
+ - lib/freeipa_easy/.user.rb.swp
87
+ - lib/freeipa_easy/user.rb
88
+ - lib/freeipa_easy/version.rb
89
+ homepage: https://github.com/arnikasky/freeipa_easy
90
+ licenses:
91
+ - MIT
92
+ metadata:
93
+ allowed_push_host: https://rubygems.org
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.4.8
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Help to work with users in freeipa
114
+ test_files: []