fastlane-plugin-firebase_app_distribution 0.3.3 → 0.3.4.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_login.rb +63 -12
- data/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb +4 -5
- data/lib/fastlane/plugin/firebase_app_distribution/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91839fcf765eec633a450478d6ea098749fbe5aface36f1ee02b0b054a4df3cf
|
4
|
+
data.tar.gz: 5548c844a4c5bfb9bd99b8895d0a2d83f2a2af0c77e030df97629183684096a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86be9d6224a6fbc54124a5f9de5d35932086eca74541b43a7adf4c23d4b4d2ffc88a0c7b8e17f6cd6aa8a4755225856e3164f622d0df52f357795e91ad7a8e57
|
7
|
+
data.tar.gz: ef77e82347bee131ab33ec38cb9c14b95db3c0b3e09969af2cf3e5c9544c4ecb5fbdb64e7d9792098f3060ba7ad18c918b27ad412b8910e109353d2a88bbc59e
|
data/lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_login.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'googleauth'
|
2
|
-
require 'googleauth/stores/file_token_store'
|
3
2
|
require "fileutils"
|
4
3
|
|
5
4
|
module Fastlane
|
6
5
|
module Actions
|
7
6
|
class FirebaseAppDistributionLoginAction < Action
|
8
|
-
OOB_URI = "urn:ietf:wg:oauth:2.0:oob"
|
9
7
|
SCOPE = "https://www.googleapis.com/auth/cloud-platform"
|
10
8
|
|
11
9
|
# In this type of application, the client secret is not treated as a secret.
|
@@ -14,24 +12,65 @@ module Fastlane
|
|
14
12
|
CLIENT_SECRET = "j9iVZfS8kkCEFUPaAeJV0sAi"
|
15
13
|
|
16
14
|
def self.run(params)
|
15
|
+
callback_uri = "http://localhost:#{params[:port]}"
|
17
16
|
client_id = Google::Auth::ClientId.new(CLIENT_ID, CLIENT_SECRET)
|
18
|
-
authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, nil)
|
19
|
-
|
17
|
+
authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, nil, callback_uri)
|
18
|
+
|
19
|
+
# Create an anti-forgery state token as described here:
|
20
|
+
# https://developers.google.com/identity/protocols/OpenIDConnect#createxsrftoken
|
21
|
+
state = SecureRandom.hex(16)
|
22
|
+
url = authorizer.get_authorization_url(state: state)
|
20
23
|
|
21
24
|
UI.message("Open the following address in your browser and sign in with your Google account:")
|
22
25
|
UI.message(url)
|
23
|
-
UI.message("")
|
24
|
-
code = UI.input("Enter the resulting code here: ")
|
25
|
-
credentials = authorizer.get_credentials_from_code(code: code, base_url: OOB_URI)
|
26
|
-
UI.message("")
|
27
26
|
|
27
|
+
response_params = get_authorization_code(params[:port])
|
28
|
+
|
29
|
+
# Confirm that the state in the response matches the state token used to
|
30
|
+
# generate the authorization URL.
|
31
|
+
unless state == response_params['state'][0]
|
32
|
+
UI.crash!('An error has occurred. The state parameter in the authorization response does not match the expected state, which could mean that a malicious attacker is trying to make a login request.')
|
33
|
+
end
|
34
|
+
|
35
|
+
user_credentials = authorizer.get_credentials_from_code(
|
36
|
+
code: response_params['code'][0]
|
37
|
+
)
|
28
38
|
UI.success("Set the refresh token as the FIREBASE_TOKEN environment variable")
|
29
|
-
UI.success("Refresh Token: #{
|
30
|
-
rescue Signet::AuthorizationError
|
31
|
-
UI.error("The code you entered is invalid. Copy and paste the code and try again.")
|
39
|
+
UI.success("Refresh Token: #{user_credentials.refresh_token}")
|
32
40
|
rescue => error
|
33
41
|
UI.error(error.to_s)
|
34
|
-
UI.crash!("An error has
|
42
|
+
UI.crash!("An error has occurred, please login again.")
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.get_authorization_code(port)
|
46
|
+
begin
|
47
|
+
server = TCPServer.open(port)
|
48
|
+
rescue Errno::EADDRINUSE => error
|
49
|
+
UI.error(error.to_s)
|
50
|
+
UI.crash!("Port #{port} is in use. Please specify a different one using the port parameter.")
|
51
|
+
end
|
52
|
+
client = server.accept
|
53
|
+
callback_request = client.readline
|
54
|
+
# Use a regular expression to extract the request line from the first line of
|
55
|
+
# the callback request, e.g.:
|
56
|
+
# GET /?code=AUTH_CODE&state=XYZ&scope=... HTTP/1.1
|
57
|
+
matcher = /GET +([^ ]+)/.match(callback_request)
|
58
|
+
response_params = CGI.parse(URI.parse(matcher[1]).query) unless matcher.nil?
|
59
|
+
|
60
|
+
client.puts("HTTP/1.1 200 OK")
|
61
|
+
client.puts("Content-Type: text/html")
|
62
|
+
client.puts("")
|
63
|
+
client.puts("<b>")
|
64
|
+
if response_params['code'].nil?
|
65
|
+
client.puts("Failed to retrieve authorization code.")
|
66
|
+
else
|
67
|
+
client.puts("Authorization code was successfully retrieved.")
|
68
|
+
end
|
69
|
+
client.puts("</b>")
|
70
|
+
client.puts("<p>Please check the console output.</p>")
|
71
|
+
client.close
|
72
|
+
|
73
|
+
return response_params
|
35
74
|
end
|
36
75
|
|
37
76
|
#####################################################
|
@@ -55,6 +94,18 @@ module Fastlane
|
|
55
94
|
def self.is_supported?(platform)
|
56
95
|
[:ios, :android].include?(platform)
|
57
96
|
end
|
97
|
+
|
98
|
+
def self.available_options
|
99
|
+
[
|
100
|
+
FastlaneCore::ConfigItem.new(key: :port,
|
101
|
+
env_name: "FIREBASEAPPDISTRO_LOGIN_PORT",
|
102
|
+
description: "Port for the local web server which receives the response from Google's authorization server",
|
103
|
+
default_value: "8081",
|
104
|
+
optional: true,
|
105
|
+
type: String)
|
106
|
+
|
107
|
+
]
|
108
|
+
end
|
58
109
|
end
|
59
110
|
end
|
60
111
|
end
|
data/lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb
CHANGED
@@ -24,13 +24,12 @@ module Fastlane
|
|
24
24
|
value
|
25
25
|
end
|
26
26
|
|
27
|
-
# Returns the array representation of a string with comma
|
28
|
-
#
|
29
|
-
# Does not work with strings whose individual values have spaces. EX "Hello World" the space will be removed to "HelloWorld"
|
27
|
+
# Returns the array representation of a string with trimmed comma
|
28
|
+
# seperated values.
|
30
29
|
def string_to_array(string)
|
31
30
|
return nil if string.nil? || string.empty?
|
32
|
-
|
33
|
-
|
31
|
+
# Strip string and then strip individual values
|
32
|
+
string.strip.split(",").map(&:strip)
|
34
33
|
end
|
35
34
|
|
36
35
|
def parse_plist(path)
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-firebase_app_distribution
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Natchev
|
8
8
|
- Manny Jimenez
|
9
9
|
- Alonso Salas Infante
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-04-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pry
|
@@ -138,7 +138,7 @@ dependencies:
|
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: 2.127.1
|
141
|
-
description:
|
141
|
+
description:
|
142
142
|
email:
|
143
143
|
- snatchev@google.com
|
144
144
|
- mannyjimenez@google.com
|
@@ -168,7 +168,7 @@ homepage: https://github.com/fastlane/fastlane-plugin-firebase_app_distribution
|
|
168
168
|
licenses:
|
169
169
|
- MIT
|
170
170
|
metadata: {}
|
171
|
-
post_install_message:
|
171
|
+
post_install_message:
|
172
172
|
rdoc_options: []
|
173
173
|
require_paths:
|
174
174
|
- lib
|
@@ -179,12 +179,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
179
|
version: '0'
|
180
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
181
|
requirements:
|
182
|
-
- - "
|
182
|
+
- - ">"
|
183
183
|
- !ruby/object:Gem::Version
|
184
|
-
version:
|
184
|
+
version: 1.3.1
|
185
185
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
187
|
-
signing_key:
|
186
|
+
rubygems_version: 3.1.4
|
187
|
+
signing_key:
|
188
188
|
specification_version: 4
|
189
189
|
summary: Release your beta builds to Firebase App Distribution. https://firebase.google.com/docs/app-distribution
|
190
190
|
test_files: []
|