rahasia 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 234adc7716ebd6db29f70d07ca8db1f69728c79beab8ee8d9eea6ed4154b60ec
4
+ data.tar.gz: '051212487974250430bf4fabad58ebda9555bcbd5a907cffd1378e0e1883b2db'
5
+ SHA512:
6
+ metadata.gz: 72e17aa0a591fbe1c0d9a99900c35b2b91568ad6484e46d3a96691659fc353bfb2646161424037dcae79afc21c1246b0825c4fd642f45e3189bd9b0bff6f0e0f
7
+ data.tar.gz: 6dcda1a8e420bd2e727bbe8ec17dd877f12e75618d35355a49acea7fd7f0066d942be6c3dc00f013fe29eb12eadc70079851633e7dde1ec5eeb17b52e482b4eb
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
@@ -0,0 +1,4 @@
1
+ fail_on_violations: true
2
+
3
+ rubocop:
4
+ config_file: .rubocop.yml
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,11 @@
1
+ Metrics/ModuleLength:
2
+ Exclude:
3
+ - "**/*_spec.rb"
4
+
5
+ Metrics/BlockLength:
6
+ Exclude:
7
+ - "**/*_spec.rb"
8
+
9
+ Metrics/LineLength:
10
+ Exclude:
11
+ - "**/*_spec.rb"
@@ -0,0 +1,12 @@
1
+ os: linux
2
+ language: ruby
3
+ before_install:
4
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
5
+ - gem install bundler -v '1.17.3'
6
+ rvm:
7
+ - 2.5.3
8
+ script:
9
+ - gem install bundler -v '1.17.3'
10
+ - bundle _1.17.3_ install
11
+ gemfile:
12
+ - gemfiles/rails_4.gemfile
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at udnpico@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ gem 'combustion', '~> 1.1'
8
+ gem 'pg', '0.15'
9
+ gem 'pry-rails'
10
+ gem 'rails', '4.2.11'
11
+ gem 'sqlite3', '~> 1.4.2'
12
+ group :test, :development do
13
+ gem 'rspec'
14
+ gem 'rspec-mocks'
15
+ gem 'rspec-rails'
16
+ # gem 'rack'
17
+ # gem 'sprockets'
18
+ # gem 'actionmailer'
19
+ # gem 'activerecord'
20
+ # gem 'actionpack' # action_controller, action_view
21
+ # gem 'sprockets'
22
+ end
23
+
24
+ # Specify your gem's dependencies in rahasia.gemspec
25
+ gemspec
@@ -0,0 +1,164 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rahasia (0.0.1.pre.alpha.pre.rc.5)
5
+ activesupport
6
+ lockbox (~> 0.3.1)
7
+ vault (~> 0.13.0)
8
+ vault-transit
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actionmailer (4.2.11)
14
+ actionpack (= 4.2.11)
15
+ actionview (= 4.2.11)
16
+ activejob (= 4.2.11)
17
+ mail (~> 2.5, >= 2.5.4)
18
+ rails-dom-testing (~> 1.0, >= 1.0.5)
19
+ actionpack (4.2.11)
20
+ actionview (= 4.2.11)
21
+ activesupport (= 4.2.11)
22
+ rack (~> 1.6)
23
+ rack-test (~> 0.6.2)
24
+ rails-dom-testing (~> 1.0, >= 1.0.5)
25
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
+ actionview (4.2.11)
27
+ activesupport (= 4.2.11)
28
+ builder (~> 3.1)
29
+ erubis (~> 2.7.0)
30
+ rails-dom-testing (~> 1.0, >= 1.0.5)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
32
+ activejob (4.2.11)
33
+ activesupport (= 4.2.11)
34
+ globalid (>= 0.3.0)
35
+ activemodel (4.2.11)
36
+ activesupport (= 4.2.11)
37
+ builder (~> 3.1)
38
+ activerecord (4.2.11)
39
+ activemodel (= 4.2.11)
40
+ activesupport (= 4.2.11)
41
+ arel (~> 6.0)
42
+ activesupport (4.2.11)
43
+ i18n (~> 0.7)
44
+ minitest (~> 5.1)
45
+ thread_safe (~> 0.3, >= 0.3.4)
46
+ tzinfo (~> 1.1)
47
+ arel (6.0.4)
48
+ aws-eventstream (1.0.3)
49
+ aws-sigv4 (1.1.0)
50
+ aws-eventstream (~> 1.0, >= 1.0.2)
51
+ builder (3.2.4)
52
+ coderay (1.1.2)
53
+ combustion (1.1.2)
54
+ activesupport (>= 3.0.0)
55
+ railties (>= 3.0.0)
56
+ thor (>= 0.14.6)
57
+ concurrent-ruby (1.1.6)
58
+ crass (1.0.6)
59
+ diff-lcs (1.3)
60
+ erubis (2.7.0)
61
+ globalid (0.4.2)
62
+ activesupport (>= 4.2.0)
63
+ i18n (0.9.5)
64
+ concurrent-ruby (~> 1.0)
65
+ lockbox (0.3.2)
66
+ loofah (2.4.0)
67
+ crass (~> 1.0.2)
68
+ nokogiri (>= 1.5.9)
69
+ mail (2.7.1)
70
+ mini_mime (>= 0.1.1)
71
+ method_source (0.9.2)
72
+ mini_mime (1.0.2)
73
+ mini_portile2 (2.4.0)
74
+ minitest (5.14.0)
75
+ nokogiri (1.10.8)
76
+ mini_portile2 (~> 2.4.0)
77
+ pg (0.15.0)
78
+ pry (0.12.2)
79
+ coderay (~> 1.1.0)
80
+ method_source (~> 0.9.0)
81
+ pry-rails (0.3.9)
82
+ pry (>= 0.10.4)
83
+ rack (1.6.13)
84
+ rack-test (0.6.3)
85
+ rack (>= 1.0)
86
+ rails (4.2.11)
87
+ actionmailer (= 4.2.11)
88
+ actionpack (= 4.2.11)
89
+ actionview (= 4.2.11)
90
+ activejob (= 4.2.11)
91
+ activemodel (= 4.2.11)
92
+ activerecord (= 4.2.11)
93
+ activesupport (= 4.2.11)
94
+ bundler (>= 1.3.0, < 2.0)
95
+ railties (= 4.2.11)
96
+ sprockets-rails
97
+ rails-deprecated_sanitizer (1.0.3)
98
+ activesupport (>= 4.2.0.alpha)
99
+ rails-dom-testing (1.0.9)
100
+ activesupport (>= 4.2.0, < 5.0)
101
+ nokogiri (~> 1.6)
102
+ rails-deprecated_sanitizer (>= 1.0.1)
103
+ rails-html-sanitizer (1.3.0)
104
+ loofah (~> 2.3)
105
+ railties (4.2.11)
106
+ actionpack (= 4.2.11)
107
+ activesupport (= 4.2.11)
108
+ rake (>= 0.8.7)
109
+ thor (>= 0.18.1, < 2.0)
110
+ rake (13.0.1)
111
+ rspec (3.9.0)
112
+ rspec-core (~> 3.9.0)
113
+ rspec-expectations (~> 3.9.0)
114
+ rspec-mocks (~> 3.9.0)
115
+ rspec-core (3.9.1)
116
+ rspec-support (~> 3.9.1)
117
+ rspec-expectations (3.9.0)
118
+ diff-lcs (>= 1.2.0, < 2.0)
119
+ rspec-support (~> 3.9.0)
120
+ rspec-mocks (3.9.1)
121
+ diff-lcs (>= 1.2.0, < 2.0)
122
+ rspec-support (~> 3.9.0)
123
+ rspec-rails (3.9.0)
124
+ actionpack (>= 3.0)
125
+ activesupport (>= 3.0)
126
+ railties (>= 3.0)
127
+ rspec-core (~> 3.9.0)
128
+ rspec-expectations (~> 3.9.0)
129
+ rspec-mocks (~> 3.9.0)
130
+ rspec-support (~> 3.9.0)
131
+ rspec-support (3.9.2)
132
+ sprockets (4.0.0)
133
+ concurrent-ruby (~> 1.0)
134
+ rack (> 1, < 3)
135
+ sprockets-rails (3.2.1)
136
+ actionpack (>= 4.0)
137
+ activesupport (>= 4.0)
138
+ sprockets (>= 3.0.0)
139
+ sqlite3 (1.4.2)
140
+ thor (1.0.1)
141
+ thread_safe (0.3.6)
142
+ tzinfo (1.2.6)
143
+ thread_safe (~> 0.1)
144
+ vault (0.13.0)
145
+ aws-sigv4
146
+ vault-transit (0.1.1)
147
+ vault (~> 0.8)
148
+
149
+ PLATFORMS
150
+ ruby
151
+
152
+ DEPENDENCIES
153
+ combustion (~> 1.1)
154
+ pg (= 0.15)
155
+ pry-rails
156
+ rahasia!
157
+ rails (= 4.2.11)
158
+ rspec
159
+ rspec-mocks
160
+ rspec-rails
161
+ sqlite3 (~> 1.4.2)
162
+
163
+ BUNDLED WITH
164
+ 1.17.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 burhanudin hakim
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.
@@ -0,0 +1,175 @@
1
+ # Rahasia
2
+
3
+ [![Build Status](https://travis-ci.org/qontak-dev/rahasia.svg?branch=master)](https://travis-ci.org/qontak-dev/rahasia)
4
+
5
+ `WARNING` this gem is alpha version. Do not use on production. Currently support String type and ActiveRecord.
6
+
7
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rahasia`. To experiment with that code, run `bin/console` for an interactive prompt.
8
+
9
+ This Gem is wrapper for [Lockbox](https://github.com/ankane/lockbox), [Vault](https://github.com/hashicorp/vault-ruby) and [Vault Transit](https://github.com/jgaxn/vault-transit).
10
+
11
+ This gem wraps the endpoints for [HashiCorp's Vault Transit secret backend](https://www.vaultproject.io/docs/secrets/transit/). It is dependent upon the [vault gem](https://github.com/hashicorp/vault-ruby). This gem has patterns and code copied from HashiCorp's [vault-ruby gem](https://github.com/hashicorp/vault-rails). Use this gem when you simply want to use the Transit secret backend and you don't need the Rails integration.
12
+
13
+ TODO: Delete this and the text above, and describe your gem
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'rahasia'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install rahasia
30
+
31
+ ## Usage
32
+
33
+ Install Library Rahasia using Rails generator
34
+
35
+ ```
36
+ rails generate rahasia:install
37
+ ```
38
+
39
+ ```ruby
40
+ # config/initializer/rahasia.rb
41
+ # frozen_string_literal: true
42
+
43
+ Rahasia.setup do |config|
44
+ config.master_key = 'please-change-me-at-config-initializers-rahasia' # SecureRandom.hex(32)
45
+ config.adapter = 'lockbox' # available ['vault','lockbox']
46
+ config.vault_app = 'qontak'
47
+ config.vault = {address: 'http://localhost', ssl_verify: false, token: 'token'}
48
+ end
49
+ ```
50
+
51
+ Create Migration to add encrypted_column
52
+
53
+ ```
54
+ rails generate rahasia:migration credentials token
55
+ ```
56
+
57
+ It will generate column `token` and `token_encrypted`. Please comment the `token` if your column already exists.
58
+
59
+ ```ruby
60
+ class RahasiaCredentialstokenUserId < ActiveRecord::Migration
61
+ def change
62
+ add_column :credentials, :token, :string
63
+ add_column :credentials, :token_encrypted, :text
64
+ end
65
+ end
66
+ ```
67
+
68
+ Run Migration on Rails
69
+
70
+ ```
71
+ bundle exec rake db:migrate
72
+ ```
73
+ ig
74
+ or for Rails 5 above
75
+
76
+ ```
77
+ bundle exec rails db:migrate
78
+ ```
79
+
80
+ ## Model
81
+
82
+ ```ruby
83
+ # app/model/credential.rb
84
+ class Credential < ActiveRecord::Base
85
+ include Rahasia
86
+ enrcypt_column :token, type: :string
87
+ end
88
+ ```
89
+ ## Lockbox
90
+
91
+ Configuration :
92
+ ```ruby
93
+ Rahasia.setup do |config|
94
+ config.master_key = 'please-change-me-at-config-initializers-rahasia'
95
+ config.adapter = 'lockbox'
96
+ end
97
+ ```
98
+
99
+ Save encryptrion
100
+ ```ruby
101
+ credential = Credential.new(token: 'ThisIsMyToken!')
102
+ credential.save
103
+
104
+ credential.token
105
+ # ThisIsMyToken!
106
+ ```
107
+
108
+ On the database save
109
+
110
+ ```ruby
111
+ credential.token
112
+ # Actual Record on Database:
113
+ # '--encrypted:29bb68380340aa4be790438e83400c30---'
114
+
115
+ # Show on irb:
116
+ # ThisIsMyToken!
117
+
118
+ credential.token_encrypted
119
+ # 7GifGwD7+Ls23FX8jyvt5JLWySPGd3300axNyc325sh/
120
+ ```
121
+ ## Vault
122
+
123
+ ```ruby
124
+ Rahasia.setup do |config|
125
+ config.adapter = 'vault'
126
+ config.vault_app = 'qontak'
127
+ config.vault = {address: 'http://localhost', ssl_verify: false, token: 'token'}
128
+ end
129
+ ```
130
+
131
+ Save encryptrion
132
+ ```ruby
133
+ credential = Credential.new(token: 'ThisIsMyToken!')
134
+ credential.save
135
+
136
+ credential.token
137
+ # ThisIsMyToken!
138
+ ```
139
+
140
+ On the database save
141
+ ```ruby
142
+ credential.token
143
+ # Actual Record on Database:
144
+ # '--encrypted:49bb68380340a23be790438e83400c29---'
145
+ # Show on irb:
146
+ # ThisIsMyToken!
147
+
148
+ credential.token_encrypted
149
+ # Actual Record on Database:
150
+ # 'vault:v1:ex/xISRe7exDqeHkIPfTeUmGusyVI/szlwRk83wGyLidc9oO+om2fp6a'
151
+ ```
152
+ ## Development
153
+
154
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
155
+
156
+ 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).
157
+
158
+ ## Contributing
159
+
160
+ Bug reports and pull requests are welcome on GitHub at https://github.com/qontak-dev/rahasia. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
161
+
162
+ TODO:
163
+
164
+ - [ ] Create Travis for Rails 4, 5, 6
165
+ - [ ] Create Travis for Ruby 2.1.0, 2.2.0, 2.3.8, 2.4.5, 2.5.3, 2.6.2
166
+ - [ ] Create test for generate installer
167
+ - [ ] Create test for generate migration
168
+
169
+ ## License
170
+
171
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
172
+
173
+ ## Code of Conduct
174
+
175
+ Everyone interacting in the Rahasia project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/qontak-dev/rahasia/blob/master/CODE_OF_CONDUCT.md).