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 Apr 6, 2022
2 parents e60757f + e423056 commit bb055ed
Show file tree
Hide file tree
Showing 15 changed files with 297 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: [1.12, 1.16]
go: [1.15, 1.16, 1.17]

steps:
- name: Set up Go ${{ matrix.go }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.12
go-version: 1.15

- name: Install golint
run: go get golang.org/x/lint/golint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.12
go-version: 1.15

- name: Install golint
run: go get golang.org/x/lint/golint
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ requests, code review feedback, and also pull requests.

## Supported Go Versions

We support Go v1.12 and higher.
The Admin Go SDK is compatible with at least the three most recent, major Go releases.
We currently support Go v1.15 and higher.
[Continuous integration](https://github.com/firebase/firebase-admin-go/actions) system
tests the code on Go v1.12 through v1.14.
tests the code on Go v1.15 through v1.17.

## Documentation

Expand Down
6 changes: 3 additions & 3 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ func NewClient(ctx context.Context, conf *internal.AuthConfig) (*Client, error)
baseURL = fmt.Sprintf("http://%s/identitytoolkit.googleapis.com", authEmulatorHost)
}
idToolkitV1Endpoint := fmt.Sprintf("%s/v1", baseURL)
idToolkitV2Beta1Endpoint := fmt.Sprintf("%s/v2beta1", baseURL)
idToolkitV2Endpoint := fmt.Sprintf("%s/v2", baseURL)
userManagementEndpoint := idToolkitV1Endpoint
providerConfigEndpoint := idToolkitV2Beta1Endpoint
tenantMgtEndpoint := idToolkitV2Beta1Endpoint
providerConfigEndpoint := idToolkitV2Endpoint
tenantMgtEndpoint := idToolkitV2Endpoint

base := &baseClient{
userManagementEndpoint: userManagementEndpoint,
Expand Down
3 changes: 2 additions & 1 deletion auth/auth_appengine.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build appengine
// +build appengine

// Copyright 2017 Google Inc. All Rights Reserved.
Expand All @@ -20,7 +21,7 @@ import (
"context"

"firebase.google.com/go/v4/internal"
"google.golang.org/appengine"
"google.golang.org/appengine/v2"
)

type aeSigner struct{}
Expand Down
1 change: 1 addition & 0 deletions auth/auth_std.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !appengine
// +build !appengine

// Copyright 2017 Google Inc. All Rights Reserved.
Expand Down
28 changes: 14 additions & 14 deletions auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ import (
)

const (
credEnvVar = "GOOGLE_APPLICATION_CREDENTIALS"
testProjectID = "mock-project-id"
testVersion = "test-version"
defaultIDToolkitV1Endpoint = "https://identitytoolkit.googleapis.com/v1"
defaultIDToolkitV2Beta1Endpoint = "https://identitytoolkit.googleapis.com/v2beta1"
credEnvVar = "GOOGLE_APPLICATION_CREDENTIALS"
testProjectID = "mock-project-id"
testVersion = "test-version"
defaultIDToolkitV1Endpoint = "https://identitytoolkit.googleapis.com/v1"
defaultIDToolkitV2Endpoint = "https://identitytoolkit.googleapis.com/v2"
)

var (
Expand Down Expand Up @@ -291,7 +291,7 @@ func TestNewClientExplicitNoAuth(t *testing.T) {
func TestNewClientEmulatorHostEnvVar(t *testing.T) {
emulatorHost := "localhost:9099"
idToolkitV1Endpoint := "http://localhost:9099/identitytoolkit.googleapis.com/v1"
idToolkitV2Beta1Endpoint := "http://localhost:9099/identitytoolkit.googleapis.com/v2beta1"
idToolkitV2Endpoint := "http://localhost:9099/identitytoolkit.googleapis.com/v2"

os.Setenv(emulatorHostEnvVar, emulatorHost)
defer os.Unsetenv(emulatorHostEnvVar)
Expand All @@ -305,11 +305,11 @@ func TestNewClientEmulatorHostEnvVar(t *testing.T) {
if baseClient.userManagementEndpoint != idToolkitV1Endpoint {
t.Errorf("baseClient.userManagementEndpoint = %q; want = %q", baseClient.userManagementEndpoint, idToolkitV1Endpoint)
}
if baseClient.providerConfigEndpoint != idToolkitV2Beta1Endpoint {
t.Errorf("baseClient.providerConfigEndpoint = %q; want = %q", baseClient.providerConfigEndpoint, idToolkitV2Beta1Endpoint)
if baseClient.providerConfigEndpoint != idToolkitV2Endpoint {
t.Errorf("baseClient.providerConfigEndpoint = %q; want = %q", baseClient.providerConfigEndpoint, idToolkitV2Endpoint)
}
if baseClient.tenantMgtEndpoint != idToolkitV2Beta1Endpoint {
t.Errorf("baseClient.tenantMgtEndpoint = %q; want = %q", baseClient.tenantMgtEndpoint, idToolkitV2Beta1Endpoint)
if baseClient.tenantMgtEndpoint != idToolkitV2Endpoint {
t.Errorf("baseClient.tenantMgtEndpoint = %q; want = %q", baseClient.tenantMgtEndpoint, idToolkitV2Endpoint)
}
if _, ok := baseClient.signer.(emulatedSigner); !ok {
t.Errorf("baseClient.signer = %#v; want = %#v", baseClient.signer, emulatedSigner{})
Expand Down Expand Up @@ -1427,11 +1427,11 @@ func checkBaseClient(client *Client, wantProjectID string) error {
if baseClient.userManagementEndpoint != defaultIDToolkitV1Endpoint {
return fmt.Errorf("userManagementEndpoint = %q; want = %q", baseClient.userManagementEndpoint, defaultIDToolkitV1Endpoint)
}
if baseClient.providerConfigEndpoint != defaultIDToolkitV2Beta1Endpoint {
return fmt.Errorf("providerConfigEndpoint = %q; want = %q", baseClient.providerConfigEndpoint, defaultIDToolkitV2Beta1Endpoint)
if baseClient.providerConfigEndpoint != defaultIDToolkitV2Endpoint {
return fmt.Errorf("providerConfigEndpoint = %q; want = %q", baseClient.providerConfigEndpoint, defaultIDToolkitV2Endpoint)
}
if baseClient.tenantMgtEndpoint != defaultIDToolkitV2Beta1Endpoint {
return fmt.Errorf("providerConfigEndpoint = %q; want = %q", baseClient.providerConfigEndpoint, defaultIDToolkitV2Beta1Endpoint)
if baseClient.tenantMgtEndpoint != defaultIDToolkitV2Endpoint {
return fmt.Errorf("providerConfigEndpoint = %q; want = %q", baseClient.providerConfigEndpoint, defaultIDToolkitV2Endpoint)
}
if baseClient.projectID != wantProjectID {
return fmt.Errorf("projectID = %q; want = %q", baseClient.projectID, wantProjectID)
Expand Down
12 changes: 12 additions & 0 deletions auth/tenant_mgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Tenant struct {
DisplayName string `json:"displayName"`
AllowPasswordSignUp bool `json:"allowPasswordSignup"`
EnableEmailLinkSignIn bool `json:"enableEmailLinkSignin"`
EnableAnonymousUsers bool `json:"enableAnonymousUser"`
}

// TenantClient is used for managing users, configuring SAML/OIDC providers, and generating email
Expand Down Expand Up @@ -216,6 +217,7 @@ const (
tenantDisplayNameKey = "displayName"
allowPasswordSignUpKey = "allowPasswordSignup"
enableEmailLinkSignInKey = "enableEmailLinkSignin"
enableAnonymousUser = "enableAnonymousUser"
)

// TenantToCreate represents the options used to create a new tenant.
Expand All @@ -240,6 +242,11 @@ func (t *TenantToCreate) EnableEmailLinkSignIn(enable bool) *TenantToCreate {
return t.set(enableEmailLinkSignInKey, enable)
}

// EnableAnonymousUsers enables or disables anonymous authentication.
func (t *TenantToCreate) EnableAnonymousUsers(enable bool) *TenantToCreate {
return t.set(enableAnonymousUser, enable)
}

func (t *TenantToCreate) set(key string, value interface{}) *TenantToCreate {
t.ensureParams().Set(key, value)
return t
Expand Down Expand Up @@ -275,6 +282,11 @@ func (t *TenantToUpdate) EnableEmailLinkSignIn(enable bool) *TenantToUpdate {
return t.set(enableEmailLinkSignInKey, enable)
}

// EnableAnonymousUsers enables or disables anonymous authentication.
func (t *TenantToUpdate) EnableAnonymousUsers(enable bool) *TenantToUpdate {
return t.set(enableAnonymousUser, enable)
}

func (t *TenantToUpdate) set(key string, value interface{}) *TenantToUpdate {
if t.params == nil {
t.params = make(nestedMap)
Expand Down
28 changes: 20 additions & 8 deletions auth/tenant_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1084,14 +1084,16 @@ const tenantResponse = `{
"name":"projects/mock-project-id/tenants/tenantID",
"displayName": "Test Tenant",
"allowPasswordSignup": true,
"enableEmailLinkSignin": true
"enableEmailLinkSignin": true,
"enableAnonymousUser": true
}`

const tenantResponse2 = `{
"name":"projects/mock-project-id/tenants/tenantID2",
"displayName": "Test Tenant 2",
"allowPasswordSignup": true,
"enableEmailLinkSignin": true
"enableEmailLinkSignin": true,
"enableAnonymousUser": true
}`

const tenantNotFoundResponse = `{
Expand All @@ -1105,13 +1107,15 @@ var testTenant = &Tenant{
DisplayName: "Test Tenant",
AllowPasswordSignUp: true,
EnableEmailLinkSignIn: true,
EnableAnonymousUsers: true,
}

var testTenant2 = &Tenant{
ID: "tenantID2",
DisplayName: "Test Tenant 2",
AllowPasswordSignUp: true,
EnableEmailLinkSignIn: true,
EnableAnonymousUsers: true,
}

func TestTenant(t *testing.T) {
Expand Down Expand Up @@ -1177,7 +1181,8 @@ func TestCreateTenant(t *testing.T) {
options := (&TenantToCreate{}).
DisplayName(testTenant.DisplayName).
AllowPasswordSignUp(testTenant.AllowPasswordSignUp).
EnableEmailLinkSignIn(testTenant.EnableEmailLinkSignIn)
EnableEmailLinkSignIn(testTenant.EnableEmailLinkSignIn).
EnableAnonymousUsers(testTenant.EnableAnonymousUsers)
tenant, err := client.TenantManager.CreateTenant(context.Background(), options)
if err != nil {
t.Fatal(err)
Expand All @@ -1191,6 +1196,7 @@ func TestCreateTenant(t *testing.T) {
"displayName": testTenant.DisplayName,
"allowPasswordSignup": testTenant.AllowPasswordSignUp,
"enableEmailLinkSignin": testTenant.EnableEmailLinkSignIn,
"enableAnonymousUser": testTenant.EnableAnonymousUsers,
}
if err := checkCreateTenantRequest(s, wantBody); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1225,7 +1231,8 @@ func TestCreateTenantZeroValues(t *testing.T) {
options := (&TenantToCreate{}).
DisplayName("").
AllowPasswordSignUp(false).
EnableEmailLinkSignIn(false)
EnableEmailLinkSignIn(false).
EnableAnonymousUsers(false)
tenant, err := client.TenantManager.CreateTenant(context.Background(), options)
if err != nil {
t.Fatal(err)
Expand All @@ -1239,6 +1246,7 @@ func TestCreateTenantZeroValues(t *testing.T) {
"displayName": "",
"allowPasswordSignup": false,
"enableEmailLinkSignin": false,
"enableAnonymousUser": false,
}
if err := checkCreateTenantRequest(s, wantBody); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1274,7 +1282,8 @@ func TestUpdateTenant(t *testing.T) {
options := (&TenantToUpdate{}).
DisplayName(testTenant.DisplayName).
AllowPasswordSignUp(testTenant.AllowPasswordSignUp).
EnableEmailLinkSignIn(testTenant.EnableEmailLinkSignIn)
EnableEmailLinkSignIn(testTenant.EnableEmailLinkSignIn).
EnableAnonymousUsers(testTenant.EnableAnonymousUsers)
tenant, err := client.TenantManager.UpdateTenant(context.Background(), "tenantID", options)
if err != nil {
t.Fatal(err)
Expand All @@ -1288,8 +1297,9 @@ func TestUpdateTenant(t *testing.T) {
"displayName": testTenant.DisplayName,
"allowPasswordSignup": testTenant.AllowPasswordSignUp,
"enableEmailLinkSignin": testTenant.EnableEmailLinkSignIn,
"enableAnonymousUser": testTenant.EnableAnonymousUsers,
}
wantMask := []string{"allowPasswordSignup", "displayName", "enableEmailLinkSignin"}
wantMask := []string{"allowPasswordSignup", "displayName", "enableAnonymousUser", "enableEmailLinkSignin"}
if err := checkUpdateTenantRequest(s, wantBody, wantMask); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -1327,7 +1337,8 @@ func TestUpdateTenantZeroValues(t *testing.T) {
options := (&TenantToUpdate{}).
DisplayName("").
AllowPasswordSignUp(false).
EnableEmailLinkSignIn(false)
EnableEmailLinkSignIn(false).
EnableAnonymousUsers(false)
tenant, err := client.TenantManager.UpdateTenant(context.Background(), "tenantID", options)
if err != nil {
t.Fatal(err)
Expand All @@ -1341,8 +1352,9 @@ func TestUpdateTenantZeroValues(t *testing.T) {
"displayName": "",
"allowPasswordSignup": false,
"enableEmailLinkSignin": false,
"enableAnonymousUser": false,
}
wantMask := []string{"allowPasswordSignup", "displayName", "enableEmailLinkSignin"}
wantMask := []string{"allowPasswordSignup", "displayName", "enableAnonymousUser", "enableEmailLinkSignin"}
if err := checkUpdateTenantRequest(s, wantBody, wantMask); err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion firebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
var defaultAuthOverrides = make(map[string]interface{})

// Version of the Firebase Go Admin SDK.
const Version = "4.7.1"
const Version = "4.8.0"

// firebaseEnvName is the name of the environment variable with the Config.
const firebaseEnvName = "FIREBASE_CONFIG"
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module firebase.google.com/go/v4

go 1.11
go 1.15

require (
cloud.google.com/go/firestore v1.5.0
cloud.google.com/go/storage v1.10.0
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99
google.golang.org/api v0.40.0
google.golang.org/appengine v1.6.7
cloud.google.com/go/firestore v1.6.1
cloud.google.com/go/storage v1.21.0
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a
google.golang.org/api v0.73.0
google.golang.org/appengine/v2 v2.0.1
)
Loading

0 comments on commit bb055ed

Please sign in to comment.