Skip to content

Commit

Permalink
Merge dev into master
Browse files Browse the repository at this point in the history
  • Loading branch information
google-oss-bot authored Sep 25, 2023
2 parents 74c9bd5 + 5e861fd commit 37c7936
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
# 3. with the label 'release:publish', and
# 4. the title prefix '[chore] Release '.
if: github.event.pull_request.merged &&
github.ref == 'dev' &&
github.ref == 'refs/heads/dev' &&
contains(github.event.pull_request.labels.*.name, 'release:publish') &&
startsWith(github.event.pull_request.title, '[chore] Release ')

Expand Down
20 changes: 12 additions & 8 deletions auth/user_mgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ type multiFactorInfoResponse struct {
EnrolledAt string `json:"enrolledAt,omitempty"`
}

type multiFactorEnrollments struct {
Enrollments []*multiFactorInfoResponse `json:"enrollments"`
}

// MultiFactorInfo describes a user enrolled second phone factor.
// TODO : convert PhoneNumber to PhoneMultiFactorInfo struct
type MultiFactorInfo struct {
Expand Down Expand Up @@ -166,18 +170,19 @@ func (u *UserToCreate) set(key string, value interface{}) *UserToCreate {

// Converts a client format second factor object to server format.
func convertMultiFactorInfoToServerFormat(mfaInfo MultiFactorInfo) (multiFactorInfoResponse, error) {
var authFactorInfo multiFactorInfoResponse
authFactorInfo := multiFactorInfoResponse{DisplayName: mfaInfo.DisplayName}
if mfaInfo.EnrollmentTimestamp != 0 {
authFactorInfo.EnrolledAt = time.Unix(mfaInfo.EnrollmentTimestamp, 0).Format("2006-01-02T15:04:05Z07:00Z")
}
if mfaInfo.UID != "" {
authFactorInfo.MFAEnrollmentID = mfaInfo.UID
}
if mfaInfo.FactorID == phoneMultiFactorID {
authFactorInfo.PhoneInfo = mfaInfo.PhoneNumber
authFactorInfo.DisplayName = mfaInfo.DisplayName
authFactorInfo.MFAEnrollmentID = mfaInfo.UID
return authFactorInfo, nil
}
out, _ := json.Marshal(mfaInfo)
return multiFactorInfoResponse{}, fmt.Errorf("Unsupported second factor %s provided", string(out))
return multiFactorInfoResponse{}, fmt.Errorf("unsupported second factor %s provided", string(out))
}

func (u *UserToCreate) validatedRequest() (map[string]interface{}, error) {
Expand Down Expand Up @@ -333,7 +338,9 @@ func (u *UserToUpdate) validatedRequest() (map[string]interface{}, error) {
if err != nil {
return nil, err
}
req["mfaInfo"] = mfaInfo

// https://cloud.google.com/identity-platform/docs/reference/rest/v1/accounts/update
req["mfa"] = multiFactorEnrollments{mfaInfo}
} else {
req[k] = v
}
Expand Down Expand Up @@ -665,9 +672,6 @@ func validateAndFormatMfaSettings(mfaSettings MultiFactorSettings, methodType st
return nil, fmt.Errorf("\"uid\" is not supported when adding second factors via \"createUser()\"")
}
case updateUserMethod:
if multiFactorInfo.UID == "" {
return nil, fmt.Errorf("the second factor \"uid\" must be a valid non-empty string when adding second factors via \"updateUser()\"")
}
default:
return nil, fmt.Errorf("unsupported methodType: %s", methodType)
}
Expand Down
25 changes: 11 additions & 14 deletions auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,17 +894,6 @@ func TestInvalidUpdateUser(t *testing.T) {
},
}),
`the second factor "phoneNumber" for "invalid" must be a non-empty E.164 standard compliant identifier string`,
}, {
(&UserToUpdate{}).MFASettings(MultiFactorSettings{
EnrolledFactors: []*MultiFactorInfo{
{
PhoneNumber: "+11234567890",
FactorID: "phone",
DisplayName: "Spouse's phone number",
},
},
}),
`the second factor "uid" must be a valid non-empty string when adding second factors via "updateUser()"`,
}, {
(&UserToUpdate{}).ProviderToLink(&UserProvider{UID: "google_uid"}),
"user provider must specify a provider ID",
Expand Down Expand Up @@ -1059,10 +1048,14 @@ var updateUserCases = []struct {
PhoneNumber: "+11234567890",
DisplayName: "Spouse's phone number",
FactorID: "phone",
}, {
PhoneNumber: "+11234567890",
DisplayName: "Spouse's phone number",
FactorID: "phone",
},
},
}),
map[string]interface{}{"mfaInfo": []*multiFactorInfoResponse{
map[string]interface{}{"mfa": multiFactorEnrollments{Enrollments: []*multiFactorInfoResponse{
{
MFAEnrollmentID: "enrolledSecondFactor1",
PhoneInfo: "+11234567890",
Expand All @@ -1074,12 +1067,16 @@ var updateUserCases = []struct {
DisplayName: "Spouse's phone number",
PhoneInfo: "+11234567890",
},
},
{
DisplayName: "Spouse's phone number",
PhoneInfo: "+11234567890",
},
}},
},
},
{
(&UserToUpdate{}).MFASettings(MultiFactorSettings{}),
map[string]interface{}{"mfaInfo": nil},
map[string]interface{}{"mfa": multiFactorEnrollments{Enrollments: nil}},
},
{
(&UserToUpdate{}).ProviderToLink(&UserProvider{
Expand Down
2 changes: 1 addition & 1 deletion firebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
var defaultAuthOverrides = make(map[string]interface{})

// Version of the Firebase Go Admin SDK.
const Version = "4.12.0"
const Version = "4.12.1"

// firebaseEnvName is the name of the environment variable with the Config.
const firebaseEnvName = "FIREBASE_CONFIG"
Expand Down
2 changes: 1 addition & 1 deletion messaging/messaging_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (c *fcmClient) SendEachDryRun(ctx context.Context, messages []*Message) (*B
return c.sendEachInBatch(ctx, messages, true)
}

// SendMulticast sends the given multicast message to all the FCM registration tokens specified.
// SendEachForMulticast sends the given multicast message to all the FCM registration tokens specified.
//
// The tokens array in MulticastMessage may contain up to 500 tokens. SendMulticast uses the
// SendEach() function to send the given message to all the target recipients. The
Expand Down

0 comments on commit 37c7936

Please sign in to comment.