obscured-doorman 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +28 -0
  3. data/.github/dependabot.yml +11 -0
  4. data/.github/workflows/publish.yml +44 -0
  5. data/.gitignore +4 -0
  6. data/.rubocop.yml +14 -0
  7. data/.ruby-gemset +1 -0
  8. data/.ruby-version +1 -0
  9. data/.simplecov +6 -0
  10. data/.travis.yml +17 -0
  11. data/CHANGELOG.md +31 -0
  12. data/Gemfile +8 -0
  13. data/Gemfile.lock +144 -0
  14. data/README.md +115 -0
  15. data/lib/obscured-doorman.rb +69 -0
  16. data/lib/obscured-doorman/base.rb +203 -0
  17. data/lib/obscured-doorman/configuration.rb +123 -0
  18. data/lib/obscured-doorman/errors.rb +44 -0
  19. data/lib/obscured-doorman/helpers.rb +66 -0
  20. data/lib/obscured-doorman/loggable.rb +51 -0
  21. data/lib/obscured-doorman/mailer.rb +46 -0
  22. data/lib/obscured-doorman/messages.rb +30 -0
  23. data/lib/obscured-doorman/models/token.rb +57 -0
  24. data/lib/obscured-doorman/models/user.rb +160 -0
  25. data/lib/obscured-doorman/providers/base/configuration.rb +69 -0
  26. data/lib/obscured-doorman/providers/bitbucket.rb +79 -0
  27. data/lib/obscured-doorman/providers/bitbucket/access_token.rb +27 -0
  28. data/lib/obscured-doorman/providers/bitbucket/configuration.rb +38 -0
  29. data/lib/obscured-doorman/providers/bitbucket/messages.rb +13 -0
  30. data/lib/obscured-doorman/providers/bitbucket/strategy.rb +53 -0
  31. data/lib/obscured-doorman/providers/github.rb +78 -0
  32. data/lib/obscured-doorman/providers/github/access_token.rb +23 -0
  33. data/lib/obscured-doorman/providers/github/configuration.rb +38 -0
  34. data/lib/obscured-doorman/providers/github/messages.rb +13 -0
  35. data/lib/obscured-doorman/providers/github/strategy.rb +53 -0
  36. data/lib/obscured-doorman/strategies/forgot_password.rb +157 -0
  37. data/lib/obscured-doorman/strategies/password.rb +38 -0
  38. data/lib/obscured-doorman/strategies/remember_me.rb +54 -0
  39. data/lib/obscured-doorman/utilities/roles.rb +11 -0
  40. data/lib/obscured-doorman/utilities/types.rb +14 -0
  41. data/lib/obscured-doorman/version.rb +7 -0
  42. data/obscured-doorman.gemspec +42 -0
  43. data/spec/config/mongoid.yml +11 -0
  44. data/spec/doorman_spec.rb +203 -0
  45. data/spec/errors_spec.rb +11 -0
  46. data/spec/factories/token_factory.rb +8 -0
  47. data/spec/factories/user_factory.rb +12 -0
  48. data/spec/helpers/application_helper.rb +52 -0
  49. data/spec/helpers/request_helper.rb +53 -0
  50. data/spec/loggable_spec.rb +27 -0
  51. data/spec/mailer_spec.rb +26 -0
  52. data/spec/matchers/time.rb +7 -0
  53. data/spec/setup.rb +58 -0
  54. data/spec/token_spec.rb +62 -0
  55. data/spec/user_spec.rb +151 -0
  56. metadata +361 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7c2276501442a13e1c1b2427c16fbfacb8dddc89bc117bd65f3ddb500c194ecf
4
+ data.tar.gz: db7403df57bce2840c586ab41c613ff2df8cf0b70ff276e4871aa6246a168086
5
+ SHA512:
6
+ metadata.gz: f9f4880d097b87bc5f762813d621d7f40d696fd1b3cdecc39af69a8a6b53dc6270e935f8e2a54b8d6ba5021a3e31a09b6c2eb324944652591c43eee7a1d36f1a
7
+ data.tar.gz: ab2ae23c201534ddc36d8dcf930e830c6a1c369e457b2ca5650d124c144df5fabcb8fd013c7d880d3681f23d1adc6421aade1e8405b39ca25e82f984ba7a6aa2
data/.codeclimate.yml ADDED
@@ -0,0 +1,28 @@
1
+ version: "2"
2
+ checks:
3
+ complex-logic:
4
+ config:
5
+ threshold: 10
6
+ file-lines:
7
+ enabled: false
8
+ method-complexity:
9
+ config:
10
+ threshold: 15
11
+ method-lines:
12
+ config:
13
+ threshold: 250
14
+ similar-code:
15
+ enabled: false
16
+ plugins:
17
+ rubocop:
18
+ enabled: true
19
+ channel: rubocop-0-71
20
+ coffeelint:
21
+ enabled: true
22
+ eslint:
23
+ enabled: true
24
+ csslint:
25
+ enabled: true
26
+ exclude_patterns:
27
+ - "tests/"
28
+ - "spec/"
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "06:00"
8
+ timezone: Europe/Stockholm
9
+ open-pull-requests-limit: 10
10
+ reviewers:
11
+ - gonace
@@ -0,0 +1,44 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: GoogleCloudPlatform/release-please-action@v2
13
+ id: release
14
+ with:
15
+ release-type: ruby
16
+ package-name: obscured-doorman
17
+ bump-minor-pre-major: true
18
+ version-file: "lib/obscured-doorman/version.rb"
19
+ # Checkout code if release was created
20
+ - uses: actions/checkout@v2
21
+ if: ${{ steps.release.outputs.release_created }}
22
+ # Setup ruby if a release was created
23
+ - uses: actions/setup-ruby@v1
24
+ with:
25
+ ruby-version: 2.7.x
26
+ if: ${{ steps.release.outputs.release_created }}
27
+ # Bundler install
28
+ - run: gem install bundler
29
+ if: ${{ steps.release.outputs.release_created }}
30
+ # Bundle install
31
+ - run: bundle install
32
+ if: ${{ steps.release.outputs.release_created }}
33
+ # Publish
34
+ - name: Publish to RubyGems
35
+ run: |
36
+ mkdir -p $HOME/.gem
37
+ touch $HOME/.gem/credentials
38
+ chmod 0600 $HOME/.gem/credentials
39
+ printf -- "---\n:rubygems_api_key: ${RUBYGEMS_AUTH_TOKEN}\n" > $HOME/.gem/credentials
40
+ gem build *.gemspec
41
+ gem push *.gem
42
+ env:
43
+ RUBYGEMS_AUTH_TOKEN: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
44
+ if: ${{ steps.release.outputs.release_created }}
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .env
2
+ .idea
3
+ .idea/
4
+ coverage/
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ Metrics/AbcSize:
2
+ Max: 50
3
+ Metrics/ClassLength:
4
+ Enabled: false
5
+ Metrics/CyclomaticComplexity:
6
+ Max: 15
7
+ Metrics/LineLength:
8
+ Enabled: false
9
+ Metrics/MethodLength:
10
+ Enabled: false
11
+ Metrics/PerceivedComplexity:
12
+ Max: 15
13
+ Naming/FileName:
14
+ Enabled: false
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ obscured-doorman
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.3
data/.simplecov ADDED
@@ -0,0 +1,6 @@
1
+ SimpleCov.start do
2
+ add_filter 'version'
3
+ add_filter '/spec/'
4
+
5
+ track_files '{lib}/**/*.rb'
6
+ end
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=032c8b6fd42bf2f80dd5e89e6bb6a70f5f6cf97771a4131a05af729001031c6e
4
+ language: ruby
5
+ bundler_args: --with development
6
+ rvm:
7
+ - 2.6.3
8
+ services:
9
+ - mongodb
10
+ before_script:
11
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12
+ - chmod +x ./cc-test-reporter
13
+ - ./cc-test-reporter before-build
14
+ script:
15
+ - bundle exec rspec
16
+ after_script:
17
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ ## [0.4.0](https://www.github.com/gonace/Obscured.Doorman/compare/v0.3.0...v0.4.0) (2021-05-13)
4
+
5
+
6
+ ### Features
7
+
8
+ * updated bundler and version ([2f7612c](https://www.github.com/gonace/Obscured.Doorman/commit/2f7612c22ee588616577fe83b321727f2ef39b98))
9
+
10
+ ## [0.3.0](https://www.github.com/gonace/Obscured.Doorman/compare/v0.2.0...v0.3.0) (2021-05-13)
11
+
12
+
13
+ ### Features
14
+
15
+ * updated bundler ([b0d86de](https://www.github.com/gonace/Obscured.Doorman/commit/b0d86de48454a19d8fd4b514d128d974d26a9d5b))
16
+ * updated bundler ([61ad991](https://www.github.com/gonace/Obscured.Doorman/commit/61ad99144678a6d6ffd1e05a9dd199480b9f8781))
17
+ * updated bundler and version ([88f39c5](https://www.github.com/gonace/Obscured.Doorman/commit/88f39c50ab111fe43540fbae0bfc2ada3a8ab5b7))
18
+
19
+ ## [0.2.0](https://www.github.com/gonace/Obscured.Doorman/compare/v0.1.0...v0.2.0) (2021-05-13)
20
+
21
+
22
+ ### Features
23
+
24
+ * added as rubygem package ([81ba8bf](https://www.github.com/gonace/Obscured.Doorman/commit/81ba8bf0ee1c05910032a17cd3c9c463c1920df6))
25
+
26
+ ## 0.1.0 (2021-05-13)
27
+
28
+
29
+ ### Features
30
+
31
+ * added as rubygem package ([88f288b](https://www.github.com/gonace/Obscured.Doorman/commit/88f288bca663733b5a9ade718932317492bbe780))
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'obscured-timeline'
6
+
7
+ # Specify your gem's dependencies in obscured-obscured-doorman.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,144 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ obscured-doorman (0.4.0)
5
+ bcrypt
6
+ geocoder
7
+ haml
8
+ mail
9
+ mongoid
10
+ rack
11
+ rack-contrib
12
+ rest-client
13
+ sinatra
14
+ sinatra-contrib
15
+ sinatra-flash
16
+ sinatra-partial
17
+ warden
18
+
19
+ GEM
20
+ remote: https://rubygems.org/
21
+ specs:
22
+ activemodel (6.1.3.2)
23
+ activesupport (= 6.1.3.2)
24
+ activesupport (6.1.3.2)
25
+ concurrent-ruby (~> 1.0, >= 1.0.2)
26
+ i18n (>= 1.6, < 2)
27
+ minitest (>= 5.1)
28
+ tzinfo (~> 2.0)
29
+ zeitwerk (~> 2.3)
30
+ bcrypt (3.1.16)
31
+ bson (4.12.0)
32
+ concurrent-ruby (1.1.8)
33
+ diff-lcs (1.4.4)
34
+ docile (1.4.0)
35
+ domain_name (0.5.20190701)
36
+ unf (>= 0.0.5, < 1.0.0)
37
+ dotenv (2.7.6)
38
+ factory_bot (6.2.0)
39
+ activesupport (>= 5.0.0)
40
+ fast-stemmer (1.0.2)
41
+ geocoder (1.6.7)
42
+ haml (5.2.1)
43
+ temple (>= 0.8.0)
44
+ tilt
45
+ http-accept (1.7.0)
46
+ http-cookie (1.0.3)
47
+ domain_name (~> 0.5)
48
+ i18n (1.8.10)
49
+ concurrent-ruby (~> 1.0)
50
+ mail (2.7.1)
51
+ mini_mime (>= 0.1.1)
52
+ mime-types (3.3.1)
53
+ mime-types-data (~> 3.2015)
54
+ mime-types-data (3.2021.0225)
55
+ mini_mime (1.1.0)
56
+ minitest (5.14.4)
57
+ mongo (2.14.0)
58
+ bson (>= 4.8.2, < 5.0.0)
59
+ mongoid (7.3.0)
60
+ activemodel (>= 5.1, < 6.2)
61
+ mongo (>= 2.10.5, < 3.0.0)
62
+ mongoid_search (0.4.0)
63
+ fast-stemmer (~> 1.0.0)
64
+ mongoid (>= 5.0.0)
65
+ multi_json (1.15.0)
66
+ mustermann (1.1.1)
67
+ ruby2_keywords (~> 0.0.1)
68
+ netrc (0.11.0)
69
+ obscured-timeline (1.0.1)
70
+ activesupport
71
+ mongoid
72
+ mongoid_search
73
+ rack (2.2.3)
74
+ rack-contrib (2.3.0)
75
+ rack (~> 2.0)
76
+ rack-protection (2.1.0)
77
+ rack
78
+ rack-test (1.1.0)
79
+ rack (>= 1.0, < 3)
80
+ rest-client (2.1.0)
81
+ http-accept (>= 1.7.0, < 2.0)
82
+ http-cookie (>= 1.0.2, < 2.0)
83
+ mime-types (>= 1.16, < 4.0)
84
+ netrc (~> 0.8)
85
+ rspec (3.10.0)
86
+ rspec-core (~> 3.10.0)
87
+ rspec-expectations (~> 3.10.0)
88
+ rspec-mocks (~> 3.10.0)
89
+ rspec-core (3.10.1)
90
+ rspec-support (~> 3.10.0)
91
+ rspec-expectations (3.10.1)
92
+ diff-lcs (>= 1.2.0, < 2.0)
93
+ rspec-support (~> 3.10.0)
94
+ rspec-mocks (3.10.2)
95
+ diff-lcs (>= 1.2.0, < 2.0)
96
+ rspec-support (~> 3.10.0)
97
+ rspec-support (3.10.2)
98
+ ruby2_keywords (0.0.4)
99
+ simplecov (0.21.2)
100
+ docile (~> 1.1)
101
+ simplecov-html (~> 0.11)
102
+ simplecov_json_formatter (~> 0.1)
103
+ simplecov-html (0.12.3)
104
+ simplecov_json_formatter (0.1.3)
105
+ sinatra (2.1.0)
106
+ mustermann (~> 1.0)
107
+ rack (~> 2.2)
108
+ rack-protection (= 2.1.0)
109
+ tilt (~> 2.0)
110
+ sinatra-contrib (2.1.0)
111
+ multi_json
112
+ mustermann (~> 1.0)
113
+ rack-protection (= 2.1.0)
114
+ sinatra (= 2.1.0)
115
+ tilt (~> 2.0)
116
+ sinatra-flash (0.3.0)
117
+ sinatra (>= 1.0.0)
118
+ sinatra-partial (1.0.1)
119
+ sinatra (>= 1.4)
120
+ temple (0.8.2)
121
+ tilt (2.0.10)
122
+ tzinfo (2.0.4)
123
+ concurrent-ruby (~> 1.0)
124
+ unf (0.1.4)
125
+ unf_ext
126
+ unf_ext (0.0.7.7)
127
+ warden (1.2.9)
128
+ rack (>= 2.0.9)
129
+ zeitwerk (2.4.2)
130
+
131
+ PLATFORMS
132
+ x86_64-linux
133
+
134
+ DEPENDENCIES
135
+ dotenv
136
+ factory_bot
137
+ obscured-doorman!
138
+ obscured-timeline
139
+ rack-test
140
+ rspec
141
+ simplecov
142
+
143
+ BUNDLED WITH
144
+ 2.2.17
data/README.md ADDED
@@ -0,0 +1,115 @@
1
+ [![Vulnerabilities](https://snyk.io/test/github/gonace/obscured.doorman/badge.svg)](https://snyk.io/test/github/gonace/obscured.doorman)
2
+ [![Build Status](https://travis-ci.org/gonace/Obscured.Doorman.svg?branch=master)](https://travis-ci.org/gonace/Obscured.Doorman)
3
+ [![Test Coverage](https://codeclimate.com/github/gonace/Obscured.Doorman/badges/coverage.svg)](https://codeclimate.com/github/gonace/Obscured.Doorman)
4
+ [![Code Climate](https://codeclimate.com/github/gonace/Obscured.Doorman/badges/gpa.svg)](https://codeclimate.com/github/gonace/Obscured.Doorman)
5
+
6
+ # Obscured::Doorman
7
+
8
+ ## Requirements
9
+ - geocoder
10
+ - haml
11
+ - mongoid
12
+ - sinatra
13
+ - sinatra-contrib
14
+ - sinatra-flash
15
+ - sinatra-partial
16
+ - rack
17
+ - rack-contrib
18
+ - rest-client
19
+ - warden
20
+
21
+ ## Installation
22
+ 1. Add this line to your application's Gemfile:
23
+ ```ruby
24
+ gem 'obscured-doorman'
25
+ ```
26
+
27
+ 2. Execute:
28
+ ```
29
+ $ bundle
30
+ ```
31
+
32
+ 3. Require the library in your application:
33
+ ```ruby
34
+ require 'obscured-doorman'
35
+ ```
36
+
37
+ ### Example
38
+ There are example html- and mail-templates in /example, look at these to get your started.
39
+
40
+ ## Configuration
41
+ The default configuration requires a mongoid client named :doorman, this will save users in a collection named 'users'
42
+ ```ruby
43
+ Obscured::Doorman.setup do |cfg|
44
+ cfg.registration = false
45
+ cfg.confirmation = false
46
+ end
47
+ ```
48
+
49
+ ### Optional Configuration & Overrides
50
+ ```ruby
51
+ Obscured::Doorman.setup do |cfg|
52
+ ...
53
+ cfg.providers = [
54
+ Obscured::Doorman::Providers::Bitbucket.setup do |c|
55
+ c.enabled = nil
56
+ c.client_id = nil
57
+ c.client_secret = nil
58
+ c.domains = nil
59
+ end,
60
+ Obscured::Doorman::Providers::GitHub.setup do |c|
61
+ c.enabled = nil
62
+ c.client_id = nil
63
+ c.client_secret = nil
64
+ c.domains = nil
65
+ end
66
+ ]
67
+ ...
68
+ end
69
+ ```
70
+
71
+
72
+ ### All possible configurations
73
+ These values are representing the default values as well as all possible configurations.
74
+
75
+ ```ruby
76
+ Obscured::Doorman.setup do |cfg|
77
+ cfg.registration = false
78
+ cfg.confirmation = false
79
+ cfg.db_name = 'doorman'
80
+ cfg.db_client = :doorman,
81
+ cfg.smtp_domain = 'doorman.local'
82
+ cfg.smtp_server = '127.0.0.1'
83
+ cfg.smtp_username = nil
84
+ cfg.smtp_password = nil
85
+ cfg.smtp_port = 25
86
+ cfg.remember_cookie = 'sinatra.doorman.remember'
87
+ cfg.remember_for = 30
88
+ cfg.use_referrer = true
89
+ cfg.providers = [
90
+ Obscured::Doorman::Providers::Bitbucket.setup do |c|
91
+ c.enabled = false
92
+ c.client_id = nil
93
+ c.client_secret = nil
94
+ c.domains = nil
95
+ end,
96
+ Obscured::Doorman::Providers::GitHub.setup do |c|
97
+ c.enabled = false
98
+ c.client_id = nil
99
+ c.client_secret = nil
100
+ c.domains = nil
101
+ end
102
+ ],
103
+ cfg.paths = {
104
+ :success => '/home',
105
+ :login => '/doorman/login',
106
+ :logout => '/doorman/logout',
107
+ :forgot => '/doorman/forgot',
108
+ :reset => '/doorman/reset'
109
+ }
110
+ )
111
+ ```
112
+
113
+ ## TODO
114
+ - Rewrite some parts to keep the gem dependencies down.
115
+ - Rewrite to drop dependencies to rest-client.