Multi-tenant authentication support in CLI (#346)

## Summary of the Pull Request

These are purposed changes to resolve ticket #344 

I have tested these changes and it does not effect or break the current functionality.

I don't necessarily expect this PR to be merged without some tweaks. I'll coordinate over the next week or so to get it right.

One coding issue I would like to discuss/highlight is the assumption (in code) that if "--tenant_domain" is used then the 'common' authority is also used. I am open to suggestions. 

## PR Checklist
* [X] Applies to work item: #344
* [X] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/onefuzz) and sign the CLI.
* [X] Tests passed (with and without multitenant authentication)
* [?] Requires documentation to be updated
* [No] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #344

## Info on Pull Request

Minor changes to the config file and the login process.

## Validation Steps Performed

Tested these changes with a multi-tenant enabled endpoint and a single-tenant endpoint.
This commit is contained in:
anslutsk
2021-01-06 04:35:47 -08:00
committed by GitHub
parent 986df8fcc6
commit 883f38cb87
2 changed files with 11 additions and 1 deletions

View File

@ -1499,6 +1499,7 @@ class Onefuzz:
client_id: Optional[str] = None,
client_secret: Optional[str] = None,
enable_feature: Optional[PreviewFeature] = None,
tenant_domain: Optional[str] = None,
) -> BackendConfig:
""" Configure onefuzz CLI """
self.logger.debug("set config")
@ -1525,6 +1526,8 @@ class Onefuzz:
self._backend.config.client_secret = client_secret
if enable_feature:
self._backend.enable_feature(enable_feature.name)
if tenant_domain is not None:
self._backend.config.tenant_domain = tenant_domain
self._backend.app = None
self._backend.save_config()