rack-change-password-url 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1fbeb94677e12c8cc859d9befd8481634ca0286dccb4f19d6135cf76ddbc7d47
4
+ data.tar.gz: '04839d68e11629e7901fdb1165d18010d5dd7650962197d88ca9b7346614a2a7'
5
+ SHA512:
6
+ metadata.gz: 52609e3749794ce3791b062ff2ce02058bbf3f039b4a7baf21498db130f9d3f30d7c055b8ab97bdb907b0cb3bb4428b6178b09f32a59b109697fc6c953b96fa4
7
+ data.tar.gz: 1e3e045fb59334ba75ef3daf66beb3da54ebb1ed60c9075135f19aba261347430fd5bd575ab4f78cfef55b02ffbb9f6d58680dbe1d4075b71db75219b8b690cd
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Taketo Takashima
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,51 @@
1
+ # Rack::ChangePasswordUrl
2
+
3
+ Provides endpoint of a Well-Known URL for Changing Passwords for Rails and Rack apps.
4
+
5
+ References:
6
+ * [A Well-Known URL for Changing Passwords | W3C](https://www.w3.org/TR/change-password-url/)
7
+
8
+ ## Installation
9
+
10
+ Install the gem and add to the application's Gemfile by executing:
11
+
12
+ $ bundle add rack-change-password-url
13
+
14
+ If bundler is not being used to manage dependencies, install the gem by executing:
15
+
16
+ $ gem install rack-change-password-url
17
+
18
+ ## Usage
19
+ ### For Rack App
20
+
21
+ ```ruby
22
+ require "rack/change-password-url"
23
+
24
+ use Rack::ChangePasswordUrl::Middleware, redirect_path: 'your-redirect-path'
25
+ ```
26
+
27
+ ### For Rails App
28
+
29
+ ```ruby
30
+ # config/application.rb
31
+ module MyApp
32
+ class Application < Rails::Application
33
+ ...
34
+ config.rack_change_password_url.redirect_path = 'your-redirect-path'
35
+ end
36
+ end
37
+ ```
38
+
39
+ ## Development
40
+
41
+ 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.
42
+
43
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/taketo1113/rack-change-password-url.
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rack
4
+ module ChangePasswordUrl
5
+ class Middleware
6
+ def initialize(app, options={})
7
+ @app = app
8
+
9
+ @redirect_path = options[:redirect_path]
10
+ end
11
+
12
+ def call(env)
13
+ req = Rack::Request.new(env)
14
+
15
+ if req.path == '/.well-known/change-password'
16
+ unless @redirect_path.nil?
17
+ return [ 302, { 'Location' => @redirect_path }, [] ]
18
+ else
19
+ raise Error.new('Failed to redirect change password url: not set redirect_path')
20
+ end
21
+ end
22
+
23
+ @app.call(env)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rack
4
+ module ChangePasswordUrl
5
+ class RailsOptions
6
+ attr_accessor :redirect_path
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'rails_options'
4
+
5
+ module Rack
6
+ module ChangePasswordUrl
7
+ class Railtie < ::Rails::Railtie
8
+ config.rack_change_password_url = RailsOptions.new
9
+
10
+ initializer "rack-change-password-url.middleware" do |app|
11
+ app.middleware.use Rack::ChangePasswordUrl::Middleware, { redirect_path: app.config.rack_change_password_url.redirect_path }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rack
4
+ module ChangePasswordUrl
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "change-password-url/middleware"
4
+ require_relative "change-password-url/version"
5
+
6
+ require_relative 'change-password-url/railtie' if defined?(::Rails)
7
+
8
+ module Rack
9
+ module ChangePasswordUrl
10
+ class Error < StandardError; end
11
+ end
12
+ end
@@ -0,0 +1 @@
1
+ require "rack/change-password-url"
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rack/change-password-url/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rack-change-password-url"
7
+ spec.version = Rack::ChangePasswordUrl::VERSION
8
+ spec.authors = ["Taketo Takashima"]
9
+ spec.email = ["t.taketo1113@gmail.com"]
10
+
11
+ spec.summary = "Provides endpoint of a Well-Known URL for Changing Passwords"
12
+ spec.description = "Provides endpoint of a Well-Known URL for Changing Passwords"
13
+ spec.homepage = "https://github.com/taketo1113/rack-change-password-url"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/taketo1113/rack-change-password-url"
19
+ spec.metadata["changelog_uri"] = "https://github.com/taketo1113/rack-change-password-url/releases"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency "rack", ">= 2.2.3.1"
33
+
34
+ spec.add_development_dependency "rake", ">= 13.0"
35
+ spec.add_development_dependency "rspec", ">= 3.0"
36
+ spec.add_development_dependency "rack-test"
37
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-change-password-url
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Taketo Takashima
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-10-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.2.3.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.2.3.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provides endpoint of a Well-Known URL for Changing Passwords
70
+ email:
71
+ - t.taketo1113@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".rspec"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/rack-change-password-url.rb
82
+ - lib/rack/change-password-url.rb
83
+ - lib/rack/change-password-url/middleware.rb
84
+ - lib/rack/change-password-url/rails_options.rb
85
+ - lib/rack/change-password-url/railtie.rb
86
+ - lib/rack/change-password-url/version.rb
87
+ - rack-change-password-url.gemspec
88
+ homepage: https://github.com/taketo1113/rack-change-password-url
89
+ licenses:
90
+ - MIT
91
+ metadata:
92
+ homepage_uri: https://github.com/taketo1113/rack-change-password-url
93
+ source_code_uri: https://github.com/taketo1113/rack-change-password-url
94
+ changelog_uri: https://github.com/taketo1113/rack-change-password-url/releases
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.6.0
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.3.7
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Provides endpoint of a Well-Known URL for Changing Passwords
114
+ test_files: []