IBM / lmctl

Cloud Pak for Network Automation (CP4NA) (previously ALM/TNCO) command line tool
Apache License 2.0
4 stars 19 forks source link

Restructure auth modes and validation in TNCOEnvironment #187

Open dvaccarosenna opened 1 year ago

dvaccarosenna commented 1 year ago

Currently we have the following auth modes:

oauth actually has 3 different types of possible authentication types:

okta has 2 different types:

zen currently only has 1 (with username & API key) but there are plans to include more.

Each of these authentication types should have their own unique auth modes, to better differentiate the expected inputs needed.

In addition, the secure flag, which pre-dates the introduction of auth_mode acts as an additional layer of auth detection. When secure is True, the auth mode is active but when secure is False, the auth mode is redundant. This can be better implemented by removing secure and adding a no auth value to auth mode.

When a TNCOEnvironment is created, the properties are validated based on the auth mode. This does not cover the fact that properties can be changed later, potentially creating an invalid TNCOEnvironment. This may result in unexpected and unclear behaviour when a client is built from the TNCOEnvironment.

The properties should be validated when they are used to build a client instead. Validation on construction of a TNCOEnvironment should be optional, to allow for properties to be populated after initial construction, something we already use to allow sensitive data to be omitted and prompted for instead.