aws-cognito-srp 0.2.0 → 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 +4 -4
- data/.github/workflows/ci.yml +26 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +4 -0
- data/README.md +10 -5
- data/aws-cognito-srp.gemspec +2 -0
- data/lib/aws/cognito_srp/version.rb +1 -1
- data/lib/aws/cognito_srp.rb +28 -2
- metadata +33 -4
- data/.github/workflows/main.yml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0d5fe8352f25fb8dd1a0512166431d191cc5615076e04ee3eae689622a51620
|
4
|
+
data.tar.gz: e94dc74f89c15baaf88f7cc46d1d012905ef8af0f904905689569d4c87919fb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c67137f6e4a7a3ad571225d64401cb719001fb59c1ac868e797872acf733e4431534bc9e8013822347a69612320f2c433e73bacf82bdf65f491989c887fccc5
|
7
|
+
data.tar.gz: 464975f0f03cea514e01a02bc2b21f89da1e5bb3d3dde73aaafeb3371b6230f5475f0f2ddd04d93b16d3a50b79d5dfc4dd5999c24de7664c4b52e6ffcbfab613
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0']
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
name: Test against Ruby ${{ matrix.ruby }}
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
bundler-cache: true
|
23
|
+
- name: Install dependencies
|
24
|
+
run: bundle install --jobs 4 --retry 3
|
25
|
+
- name: Run specs
|
26
|
+
run: bundle exec rspec spec --backtrace
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Aws::CognitoSrp for Ruby
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/aws-cognito-srp)
|
4
|
-
|
4
|
+

|
5
5
|
|
6
6
|
An unofficial Ruby library implementing
|
7
7
|
[AWS Cognito's SRP authentication flow](https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-authentication-flow.html#Using-SRP-password-verification-in-custom-authentication-flow).
|
@@ -29,15 +29,20 @@ aws_srp = Aws::CognitoSrp.new(
|
|
29
29
|
password: "password",
|
30
30
|
pool_id: "pool-id",
|
31
31
|
client_id: "client-id",
|
32
|
-
aws_client: Aws::CognitoIdentityProvider::Client.new(region: "
|
32
|
+
aws_client: Aws::CognitoIdentityProvider::Client.new(region: "aws-region")
|
33
33
|
)
|
34
34
|
|
35
|
-
aws_srp.authenticate
|
35
|
+
resp = aws_srp.authenticate
|
36
|
+
|
37
|
+
# Read tokens
|
38
|
+
resp.id_token
|
39
|
+
resp.access_token
|
40
|
+
resp.refresh_token
|
36
41
|
```
|
37
42
|
|
38
|
-
##
|
43
|
+
## Supported rubies
|
39
44
|
|
40
|
-
|
45
|
+
This gem is tested against and supports Ruby 2.3, 2.4, 2.5, 2.6, 2.7 and 3.0.
|
41
46
|
|
42
47
|
## Development
|
43
48
|
|
data/aws-cognito-srp.gemspec
CHANGED
@@ -25,6 +25,8 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 2.2.0"
|
26
26
|
spec.add_development_dependency "rake", "~> 13.0"
|
27
27
|
spec.add_development_dependency "ox", "~> 2.14.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency "pry"
|
28
30
|
|
29
31
|
# For more information and examples about making a new gem, checkout our
|
30
32
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/aws/cognito_srp.rb
CHANGED
@@ -10,6 +10,33 @@ require "base64"
|
|
10
10
|
require "aws/cognito_srp/version"
|
11
11
|
require "aws/cognito_srp/errors"
|
12
12
|
|
13
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5")
|
14
|
+
module IntegerWithPow
|
15
|
+
refine Integer do
|
16
|
+
# Integer#pow was introduced in Ruby 2.5
|
17
|
+
# Use OpenSSL's modular exponentiation in older Rubies
|
18
|
+
def pow(b, m)
|
19
|
+
self.to_bn.mod_exp(b, m).to_i
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
using IntegerWithPow
|
25
|
+
end
|
26
|
+
|
27
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.4")
|
28
|
+
module StringWithUnpack1
|
29
|
+
refine String do
|
30
|
+
# String#unpack1 was introduced in Ruby 2.4
|
31
|
+
def unpack1(fmt)
|
32
|
+
unpack(fmt)[0]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
using StringWithUnpack1
|
38
|
+
end
|
39
|
+
|
13
40
|
module Aws
|
14
41
|
# Client for AWS Cognito Identity Provider using Secure Remote Password (SRP).
|
15
42
|
#
|
@@ -175,8 +202,7 @@ module Aws
|
|
175
202
|
end
|
176
203
|
|
177
204
|
def get_random(nbytes)
|
178
|
-
|
179
|
-
hex_to_long(random_hex)
|
205
|
+
hex_to_long(bytes_to_hex(::SecureRandom.gen_random(nbytes)))
|
180
206
|
end
|
181
207
|
|
182
208
|
def pad_hex(long_int)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-cognito-srp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Viney
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-09-
|
13
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk-cognitoidentityprovider
|
@@ -68,6 +68,34 @@ dependencies:
|
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: 2.14.0
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rspec
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '3.0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: pry
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
71
99
|
description: Unofficial Ruby library implementing AWS Cognito's SRP authentication
|
72
100
|
flow
|
73
101
|
email:
|
@@ -76,8 +104,9 @@ executables: []
|
|
76
104
|
extensions: []
|
77
105
|
extra_rdoc_files: []
|
78
106
|
files:
|
79
|
-
- ".github/workflows/
|
107
|
+
- ".github/workflows/ci.yml"
|
80
108
|
- ".gitignore"
|
109
|
+
- ".rspec"
|
81
110
|
- CHANGELOG.md
|
82
111
|
- Gemfile
|
83
112
|
- LICENSE
|
@@ -110,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
139
|
- !ruby/object:Gem::Version
|
111
140
|
version: '0'
|
112
141
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.0.6
|
114
143
|
signing_key:
|
115
144
|
specification_version: 4
|
116
145
|
summary: AWS Cognito SRP auth for Ruby
|
data/.github/workflows/main.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
name: Ruby
|
2
|
-
|
3
|
-
on: [push,pull_request]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
build:
|
7
|
-
runs-on: ubuntu-latest
|
8
|
-
steps:
|
9
|
-
- uses: actions/checkout@v2
|
10
|
-
- name: Set up Ruby
|
11
|
-
uses: ruby/setup-ruby@v1
|
12
|
-
with:
|
13
|
-
ruby-version: 3.0.0
|
14
|
-
bundler-cache: true
|
15
|
-
- name: Run the default task
|
16
|
-
run: bundle exec rake
|