contrib-auth 0.3.1 → 0.4.1
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/app/controllers/contrib/auth/authentication_controller.rb +19 -0
- data/app/views/contrib/auth/authentication/sign_up_with_email_or_username_and_password.json.jbuilder +1 -0
- data/config/routes.rb +3 -0
- data/lib/contrib/auth/api.rb +11 -0
- data/lib/contrib/auth/provider/google_auth.rb +7 -0
- data/lib/contrib/auth/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef320c78fd097c24090a4635394bad139b57dbed7ef3e78998238afc9243dc10
|
4
|
+
data.tar.gz: f0482456dd9e97403bcaf3c2015d44c28154d61c86aa93721945aa3645ba855d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad3e8db46f1e149228455398dce3842ac964403e02f6e4c2dd4e90b38489954f8e5045cd13acf229e772d5900c3d8c674e206ea44ea9bdf67f239cbf699a495
|
7
|
+
data.tar.gz: 155144638f18b43ab8e18cb065c26a4be7cc46c4ab1455f333127cfe1ee2d6546e928c211b54440435b895dee92f8494ae5fec237e2ff23f2b5e2ec8ce701bbb
|
@@ -7,6 +7,25 @@ module Contrib
|
|
7
7
|
params[:password]
|
8
8
|
)
|
9
9
|
end
|
10
|
+
|
11
|
+
def reset_password
|
12
|
+
@response = Contrib::Auth::api.reset_password(
|
13
|
+
params[:email_or_username]
|
14
|
+
)
|
15
|
+
|
16
|
+
render json: {}, status: :ok
|
17
|
+
end
|
18
|
+
|
19
|
+
def sign_up_with_email_or_username_and_password
|
20
|
+
@response = Contrib::Auth.api.sign_up_with_email_and_password(
|
21
|
+
params[:email_or_username],
|
22
|
+
params[:password]
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def certificates
|
27
|
+
render json: Contrib::Auth.api.certificates, status: :ok
|
28
|
+
end
|
10
29
|
end
|
11
30
|
end
|
12
31
|
end
|
data/app/views/contrib/auth/authentication/sign_up_with_email_or_username_and_password.json.jbuilder
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
json.extract!(@response, :id_token, :refresh_token, :expires_in)
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
Contrib::Auth::Engine.routes.draw do
|
2
2
|
defaults format: :json do
|
3
3
|
post '/sign_in_with_password' => 'authentication#sign_in_with_password'
|
4
|
+
post '/reset_password' => 'authentication#reset_password'
|
5
|
+
post '/sign_up_with_email_or_username_and_password' => 'authentication#sign_up_with_email_or_username_and_password'
|
6
|
+
get '/certificates' => 'authentication#certificates'
|
4
7
|
end
|
5
8
|
end
|
data/lib/contrib/auth/api.rb
CHANGED
@@ -6,7 +6,10 @@ module Contrib
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def sign_in_with_password(email_or_username, password)
|
9
|
+
raise ArgumentError unless email_or_username
|
10
|
+
raise ArgumentError unless password
|
9
11
|
# TODO: Implement retryable
|
12
|
+
# TODO: Validate incoming attributes
|
10
13
|
@provider.sign_in_with_password(email_or_username, password)
|
11
14
|
end
|
12
15
|
|
@@ -15,8 +18,16 @@ module Contrib
|
|
15
18
|
end
|
16
19
|
|
17
20
|
def sign_up_with_email_and_password(email_or_username, password)
|
21
|
+
raise ArgumentError unless email_or_username
|
22
|
+
raise ArgumentError unless password
|
23
|
+
|
24
|
+
# TODO: ask for password confirmation
|
18
25
|
@provider.sign_up_with_email_and_password(email_or_username, password)
|
19
26
|
end
|
27
|
+
|
28
|
+
def certificates
|
29
|
+
@provider.certificates
|
30
|
+
end
|
20
31
|
end
|
21
32
|
end
|
22
33
|
end
|
@@ -5,6 +5,7 @@ module Contrib
|
|
5
5
|
module Provider
|
6
6
|
class GoogleAuth
|
7
7
|
DEFAULT_BASE_ENDPOINT = 'https://identitytoolkit.googleapis.com'.freeze
|
8
|
+
PUBLIC_KEYS_URI = 'https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com'.freeze
|
8
9
|
|
9
10
|
def initialize(api_key, http_client = Faraday.new(DEFAULT_BASE_ENDPOINT))
|
10
11
|
@api_key = api_key
|
@@ -70,6 +71,12 @@ module Contrib
|
|
70
71
|
|
71
72
|
response.success?
|
72
73
|
end
|
74
|
+
|
75
|
+
# refers to: https://firebase.google.com/docs/auth/admin/verify-id-tokens
|
76
|
+
def certificates
|
77
|
+
response = @http_client.get(PUBLIC_KEYS_URI)
|
78
|
+
JSON.parse(response.body)
|
79
|
+
end
|
73
80
|
end
|
74
81
|
end
|
75
82
|
end
|
data/lib/contrib/auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contrib-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contribyard Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- app/mailers/contrib/auth/application_mailer.rb
|
78
78
|
- app/models/contrib/auth/application_record.rb
|
79
79
|
- app/views/contrib/auth/authentication/sign_in_with_password.json.jbuilder
|
80
|
+
- app/views/contrib/auth/authentication/sign_up_with_email_or_username_and_password.json.jbuilder
|
80
81
|
- config/routes.rb
|
81
82
|
- lib/contrib/auth.rb
|
82
83
|
- lib/contrib/auth/api.rb
|