Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateTenant with SourceTenantId does not behave as expected #62

Open
josedelrio85 opened this issue Feb 17, 2022 · 2 comments
Open

CreateTenant with SourceTenantId does not behave as expected #62

josedelrio85 opened this issue Feb 17, 2022 · 2 comments

Comments

@josedelrio85
Copy link

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.
@josedelrio85 josedelrio85 changed the title Create tenant with SourceTenantId does not behave as expected CreateTenant with SourceTenantId does not behave as expected Feb 17, 2022
@mooreds
Copy link
Contributor

mooreds commented Feb 22, 2022

@josedelrio85 hmmm. So re-reading the issue, it appears that the client and the tenant API have different behavior when additional fields are added to a sourceTenantId call.

Is that correct?

One workaround is to create the tenant in two steps. Will that not work for you for some reason?

@josedelrio85
Copy link
Author

@mooreds Yes, the behaviour differs between a direct API call and the use of the library.

From my point of view, and following the indication in the documentation, I understand that the behaviour of the library function should be corrected.

I really opened the issue to comment on this difference so that you would be aware of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants