vp-login 0.3.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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +109 -0
- data/lib/vplogin/admin.rb +223 -0
- data/lib/vplogin/claims.rb +29 -0
- data/lib/vplogin/configuration.rb +116 -0
- data/lib/vplogin/controller.rb +147 -0
- data/lib/vplogin/devise_token_auth_controller.rb +55 -0
- data/lib/vplogin/devise_token_auth_logout.rb +36 -0
- data/lib/vplogin/devise_user.rb +96 -0
- data/lib/vplogin/discovery.rb +47 -0
- data/lib/vplogin/errors.rb +64 -0
- data/lib/vplogin/http.rb +76 -0
- data/lib/vplogin/memory_cache.rb +49 -0
- data/lib/vplogin/oidc.rb +141 -0
- data/lib/vplogin/password_check.rb +59 -0
- data/lib/vplogin/pkce.rb +26 -0
- data/lib/vplogin/railtie.rb +10 -0
- data/lib/vplogin/routes.rb +14 -0
- data/lib/vplogin/state_store.rb +62 -0
- data/lib/vplogin/version.rb +5 -0
- data/lib/vplogin.rb +50 -0
- metadata +142 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module VpLogin
|
|
4
|
+
# Two single-use cache entries per login:
|
|
5
|
+
# attempt - keyed by OIDC `state`, written when the login starts, consumed by the callback.
|
|
6
|
+
# handoff - keyed by a fresh random code the callback gives the frontend, consumed by verify.
|
|
7
|
+
# The authorization code itself never reaches the browser.
|
|
8
|
+
#
|
|
9
|
+
# read+delete is not atomic. A concurrent double redeem is still harmless: vpLogin only lets
|
|
10
|
+
# an authorization code be exchanged once.
|
|
11
|
+
class StateStore
|
|
12
|
+
ID_FORMAT = /\A[A-Za-z0-9_-]{1,200}\z/
|
|
13
|
+
|
|
14
|
+
def initialize(config = VpLogin.configuration)
|
|
15
|
+
@config = config
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def write_attempt(state, attempt)
|
|
19
|
+
write(:attempt, state, attempt, @config.state_ttl)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def take_attempt(state)
|
|
23
|
+
take(:attempt, state)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Without consuming it, for callers that must refuse before spending the state.
|
|
27
|
+
def read_attempt(state)
|
|
28
|
+
return nil unless state.is_a?(String) && state.match?(ID_FORMAT)
|
|
29
|
+
|
|
30
|
+
@config.cache.read(key(:attempt, state))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def write_handoff(attempt)
|
|
34
|
+
code = SecureRandom.hex(32)
|
|
35
|
+
write(:handoff, code, attempt, @config.handoff_ttl)
|
|
36
|
+
code
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def take_handoff(code)
|
|
40
|
+
take(:handoff, code)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def write(kind, id, value, ttl)
|
|
46
|
+
@config.cache.write(key(kind, id), value, expires_in: ttl)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def take(kind, id)
|
|
50
|
+
return nil unless id.is_a?(String) && id.match?(ID_FORMAT)
|
|
51
|
+
|
|
52
|
+
cache_key = key(kind, id)
|
|
53
|
+
value = @config.cache.read(cache_key)
|
|
54
|
+
@config.cache.delete(cache_key) unless value.nil?
|
|
55
|
+
value
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def key(kind, id)
|
|
59
|
+
"#{@config.cache_namespace}:#{kind}:#{id}"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
data/lib/vplogin.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'base64'
|
|
4
|
+
require 'digest'
|
|
5
|
+
require 'json'
|
|
6
|
+
require 'logger'
|
|
7
|
+
require 'net/http'
|
|
8
|
+
require 'openssl'
|
|
9
|
+
require 'securerandom'
|
|
10
|
+
require 'uri'
|
|
11
|
+
require 'jwt'
|
|
12
|
+
|
|
13
|
+
require_relative 'vplogin/version'
|
|
14
|
+
require_relative 'vplogin/errors'
|
|
15
|
+
require_relative 'vplogin/memory_cache'
|
|
16
|
+
require_relative 'vplogin/configuration'
|
|
17
|
+
require_relative 'vplogin/http'
|
|
18
|
+
require_relative 'vplogin/pkce'
|
|
19
|
+
require_relative 'vplogin/claims'
|
|
20
|
+
require_relative 'vplogin/state_store'
|
|
21
|
+
require_relative 'vplogin/discovery'
|
|
22
|
+
require_relative 'vplogin/oidc'
|
|
23
|
+
require_relative 'vplogin/admin'
|
|
24
|
+
require_relative 'vplogin/password_check'
|
|
25
|
+
|
|
26
|
+
module VpLogin
|
|
27
|
+
class << self
|
|
28
|
+
def configuration
|
|
29
|
+
@configuration ||= Configuration.new
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def configure
|
|
33
|
+
yield configuration
|
|
34
|
+
configuration
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def reset_configuration!
|
|
38
|
+
@configuration = nil
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if defined?(::Rails::Railtie)
|
|
44
|
+
require_relative 'vplogin/controller'
|
|
45
|
+
require_relative 'vplogin/devise_token_auth_controller'
|
|
46
|
+
require_relative 'vplogin/devise_token_auth_logout'
|
|
47
|
+
require_relative 'vplogin/devise_user'
|
|
48
|
+
require_relative 'vplogin/routes'
|
|
49
|
+
require_relative 'vplogin/railtie'
|
|
50
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: vp-login
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.3.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Volopay
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-11-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: jwt
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.5'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '4'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '2.5'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '4'
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: actionpack
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '7.0'
|
|
40
|
+
type: :development
|
|
41
|
+
prerelease: false
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '7.0'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: activejob
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '7.0'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '7.0'
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: rspec
|
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '3.9'
|
|
68
|
+
type: :development
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '3.9'
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: webmock
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '3.19'
|
|
82
|
+
type: :development
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '3.19'
|
|
89
|
+
description:
|
|
90
|
+
email:
|
|
91
|
+
executables: []
|
|
92
|
+
extensions: []
|
|
93
|
+
extra_rdoc_files: []
|
|
94
|
+
files:
|
|
95
|
+
- LICENSE.txt
|
|
96
|
+
- README.md
|
|
97
|
+
- lib/vplogin.rb
|
|
98
|
+
- lib/vplogin/admin.rb
|
|
99
|
+
- lib/vplogin/claims.rb
|
|
100
|
+
- lib/vplogin/configuration.rb
|
|
101
|
+
- lib/vplogin/controller.rb
|
|
102
|
+
- lib/vplogin/devise_token_auth_controller.rb
|
|
103
|
+
- lib/vplogin/devise_token_auth_logout.rb
|
|
104
|
+
- lib/vplogin/devise_user.rb
|
|
105
|
+
- lib/vplogin/discovery.rb
|
|
106
|
+
- lib/vplogin/errors.rb
|
|
107
|
+
- lib/vplogin/http.rb
|
|
108
|
+
- lib/vplogin/memory_cache.rb
|
|
109
|
+
- lib/vplogin/oidc.rb
|
|
110
|
+
- lib/vplogin/password_check.rb
|
|
111
|
+
- lib/vplogin/pkce.rb
|
|
112
|
+
- lib/vplogin/railtie.rb
|
|
113
|
+
- lib/vplogin/routes.rb
|
|
114
|
+
- lib/vplogin/state_store.rb
|
|
115
|
+
- lib/vplogin/version.rb
|
|
116
|
+
homepage:
|
|
117
|
+
licenses:
|
|
118
|
+
- MIT
|
|
119
|
+
metadata:
|
|
120
|
+
allowed_push_host: https://rubygems.org
|
|
121
|
+
rubygems_mfa_required: 'true'
|
|
122
|
+
post_install_message:
|
|
123
|
+
rdoc_options: []
|
|
124
|
+
require_paths:
|
|
125
|
+
- lib
|
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - ">="
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '3.1'
|
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
|
+
requirements:
|
|
133
|
+
- - ">="
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
version: '0'
|
|
136
|
+
requirements: []
|
|
137
|
+
rubygems_version: 3.4.10
|
|
138
|
+
signing_key:
|
|
139
|
+
specification_version: 4
|
|
140
|
+
summary: Relying-party integration for vpLogin (OIDC login, ID token verification,
|
|
141
|
+
admin API).
|
|
142
|
+
test_files: []
|