8.3 Gateway Config Secrets

Is there any examples of a gateway config with secrets (Device login passwords or similar) for 8.3? I have worked out most of the rest, I just seem to be missing something to enable the password to save.

You're using SecretConfig for the field type in your config class? Is this an ExtensionPointResourceForm or something custom?

@Nonnull
@Required
@FormCategory("SETTINGS")
@Label("Password")
@FormField(FormFieldType.SECRET)
SecretConfig password,

This appears fine, but I don't seem to be able to get the non-secret text back out later in the module, so I was hoping there was an example of that mechanism around.

public Connection(String host, String user, Secret password, boolean secure, boolean ackEnabled) throws SecretException {
    try {
            this.password = password.getPlaintext().getAsString();
        } catch (SecretException e) {
            throw new RuntimeException(e);
        }
GatewayContext context = ...;
SecretConfig password = ...;

Secret<?> secret = Secret.create(context, password);

secret.getPlaintext().getAsBytes();
secret.getPlaintext().getAsString();
6 Likes

Just as another reference / example: we recently added a Mongo DB backed user source profile in the SDK examples which retrieves the Mongo DB password as a secret: ignition-sdk-examples/user-source-profile/user-source-gateway/src/main/java/com/inductiveautomation/ignition/examples/usersource/mongodb/MongoDbUserSource.java at f9aa673775043d4dafb0eddcc77981645528a2a2 · inductiveautomation/ignition-sdk-examples · GitHub

1 Like