fastlane-plugin-firebase_app_distribution 0.3.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a1fbbe97c9bb43345aa73b821b9a0f192bbd0f6820917923927377880f58b03
4
- data.tar.gz: 40cf095bae9f86eb68015545991ccdcae9b2024851cb2e991d12c6f145cf68f8
3
+ metadata.gz: bc0ef3ef05eb625935ee2ffe519516cb5c31efdb045042ed3a81dd6594e1e136
4
+ data.tar.gz: eedd839c8830652d9cb8aa3588d4383f2772bc7f448f118984c7141bf83182c6
5
5
  SHA512:
6
- metadata.gz: 6b1c43fd6f71064334580d10842a1e1b31904e769140124ea5bbca7f6111771c5611fc9e74e08e6b5039ee38e8a0996f020a0ae2abdccd2f0f9438273b2514b4
7
- data.tar.gz: 32491201cbcc854397f498b7c7064d296fe4220396afdf46d3c9a600e58af1f0af8ba9a2b74a4127cc6d87639fb6e9320cf4173076f9bf9a03b9a675c83bdaa8
6
+ metadata.gz: d3ccabcac5711e12dfe049539f312e40a6842fe99dfd74749777702f17ee316a6455b25badb21d6179cabfad44e898a70c8f039a5c506be334de8e43bfc9fed4
7
+ data.tar.gz: bf5500a20cbb7783859dd8db9206acf517e39cf89538d49a283af69a6fd08fcf652ce3180e7d2be11ed75f590b025e2fb7e1fadc24df86fd4e6b914d03923f04
@@ -201,12 +201,12 @@ module Fastlane
201
201
  type: String),
202
202
  FastlaneCore::ConfigItem.new(key: :groups,
203
203
  env_name: "FIREBASEAPPDISTRO_GROUPS",
204
- description: "The groups used for distribution, separated by commas",
204
+ description: "The group aliases used for distribution, separated by commas",
205
205
  optional: true,
206
206
  type: String),
207
207
  FastlaneCore::ConfigItem.new(key: :groups_file,
208
208
  env_name: "FIREBASEAPPDISTRO_GROUPS_FILE",
209
- description: "The groups used for distribution, separated by commas",
209
+ description: "The group aliases used for distribution, separated by commas",
210
210
  optional: true,
211
211
  type: String),
212
212
  FastlaneCore::ConfigItem.new(key: :testers,
@@ -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
- url = authorizer.get_authorization_url(base_url: OOB_URI)
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: #{credentials.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 occured, please login again.")
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,28 @@ 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
109
+
110
+ def self.category
111
+ :deprecated
112
+ end
113
+
114
+ def self.deprecated_notes
115
+ "The firebase_app_distribution_login task is deprecated and will be removed in Q1 2023. See "\
116
+ "https://firebase.google.com/docs/app-distribution/android/distribute-gradle#authenticate "\
117
+ "for more information on alternative ways to authenticate."
118
+ end
58
119
  end
59
120
  end
60
121
  end
@@ -46,7 +46,7 @@ module Fastlane
46
46
  request.headers[CONTENT_TYPE] = APPLICATION_JSON
47
47
  end
48
48
  rescue Faraday::ClientError
49
- UI.user_error!("#{ErrorMessage::INVALID_TESTERS} \nEmails: #{emails} \nGroups: #{group_aliases}")
49
+ UI.user_error!("#{ErrorMessage::INVALID_TESTERS} \nEmails: #{emails} \nGroup Aliases: #{group_aliases}")
50
50
  end
51
51
  UI.success("✅ Added testers/groups.")
52
52
  end
@@ -11,7 +11,7 @@ module ErrorMessage
11
11
  INVALID_APP_ID = "App Distribution could not find your app. Make sure to onboard your app by pressing the \"Get started\" button on the App Distribution page in the Firebase console: https://console.firebase.google.com/project/_/appdistribution. App ID"
12
12
  INVALID_PROJECT = "App Distribution could not find your Firebase project. Make sure to onboard an app in your project by pressing the \"Get started\" button on the App Distribution page in the Firebase console: https://console.firebase.google.com/project/_/appdistribution."
13
13
  INVALID_PATH = "Could not read content from"
14
- INVALID_TESTERS = "Could not enable access for testers. Check that the groups exist and the tester emails are formatted correctly"
14
+ INVALID_TESTERS = "Could not enable access for testers. Check that the tester emails are formatted correctly, the groups exist and you are using group aliases (not group names) for specifying groups."
15
15
  INVALID_RELEASE_NOTES = "Failed to add release notes"
16
16
  SERVICE_CREDENTIALS_ERROR = "App Distribution could not generate credentials from the service credentials file specified"
17
17
  PLAY_ACCOUNT_NOT_LINKED = "This project is not linked to a Google Play account."
@@ -24,13 +24,12 @@ module Fastlane
24
24
  value
25
25
  end
26
26
 
27
- # Returns the array representation of a string with comma seperated values.
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
- string_array = string.gsub(/\s+/, '').split(",")
33
- return string_array
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)
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module FirebaseAppDistribution
3
- VERSION = "0.3.3"
3
+ VERSION = "0.3.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Natchev
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-03-22 00:00:00.000000000 Z
13
+ date: 2022-07-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0'
185
185
  requirements: []
186
- rubygems_version: 3.2.32
186
+ rubygems_version: 3.0.3.1
187
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