Skip to content

CreateTenant with SourceTenantId does not behave as expected #62

@josedelrio85

Description

@josedelrio85

I have created a tenant using Tenant APIs using the Default Tenant as a base, but trying to add customisations, in this case email settings.

POST api/tenant

{
  "tenant": {
    "sourceTenantId": "1477a639-1027-1fdb-b6cc-f19a162865a9",
    "name": "foo",
    "issuer":"foobar.com",
    "emailConfiguration":{
      "defaultFromEmail":"[email protected]",
      "defaultFromName":"FooBar",
      "host":"smtp.foobar.com",
      "implicitEmailVerificationAllowed":false,
      "password":"password",
      "port":465,
      "security":"SSL",
      "username":"foobar"
    },
    "passwordEncryptionConfiguration":{
      "encryptionScheme":"bcrypt",
      "encryptionSchemeFactor":6
    }
  }
}

The result is satisfactory, as I get the new Tenant with the default configuration plus the customisations specified in the request.

On the other hand, when using the CreateTenant method of the client, if I specify in the SourceTenantId property the identifier of the base Tenant, the resulting Tenant does not have the custom properties.

func (h *Handler) CreateTenant(name string) (*fusionauth.TenantResponse, *fusionauth.Errors, error) {
	tr := fusionauth.TenantRequest{
                // if this property is uncommented, the result is the configuration of DefaultTenant
		// SourceTenantId: "1477a639-1027-1fdb-b6cc-f19a162865a9",
		Tenant: fusionauth.Tenant{
			Name:   name,
			Issuer: "udrafter.com",
			EmailConfiguration: fusionauth.EmailConfiguration{
				DefaultFromEmail:                 "[email protected]",
				DefaultFromName:                  "foobar",
				Host:                             "smt.foobar.com",
				ImplicitEmailVerificationAllowed: false,
				Password:                         "password",
				Port:                             465,
				Security:                         "SSL",
				Username:                         "foobar",
			},
			PasswordEncryptionConfiguration: fusionauth.PasswordEncryptionConfiguration{
				EncryptionScheme:       "bcrypt",
				EncryptionSchemeFactor: 6,
			},
		},
	}
	r, faerrors, err := h.FusionAuth.CreateTenant("", tr)
	if err != nil {
		return nil, faerrors, err
	}
	return r, faerrors, nil
}

I understand that this behaviour does not correspond to the behaviour obtained using Tenant APIs and to what is discussed in this section of the documentation:

sourceTenantId [UUID] OPTIONAL AVAILABLE SINCE 1.14.0
The optional Id of an existing Tenant to make a copy of. A unique tenant.name is required. If present, the tenant.id value will used for the new Tenant. All other values will be copied from the source Tenant to the new Tenant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions