Login with SSO or LDAP and/or using import_from_cf_cli within the library
svenXY opened this issue · 8 comments
Hi,
the cf tools provide some means of login in with SSO
cf login -a api.example.com --sso
(which then queries for a temporary authentication code) - or can this temporary code be used somehow?
as well as via LDAP:
cf login -a api.example.com --origin=ldap -u <user>
Can any of these be used with cf-python-client and if so, how?
Furthermore, there is
cloudfoundry-client import_from_cf_cli
which, if I understand correctly, uses the token created by cf login. Is there any possibility of using this feature in the library as well?
Thanks a lot,
Sven
def login_with_cf_config(self):
with open(Path.home() / '.cf/config.json', 'r') as f:
cf_config = json.load(f)
self.client = CloudFoundryClient(cf_config['Target'], verify=False)
self.client.init_with_token(cf_config['RefreshToken'])
does the trick
But the question for sso and /or ldap remains ;-)
@svenXY let's submit a pull request then 😊
I'm not sure where to patch it in though as CloudFoundryClient must already be called with a target_endpoint. I could make something like:
Set target_endpoint to "from_cf_config" instead of a url to then trigger methods to retrieve data from there. This would probably make it possible to then use the init_with_token method.
What do you think?
Yes. Maybe a static method named build_from_cf_config_file
taking a path in parameter default to user default cf config file would do the trick?
Hi, @antechrestos , did you see my PR?
Hi @antechrestos, I opened #175 which implements the staticmethod you proposed as an alternative
Hi @antechrestos, I opened #175 which implements the staticmethod you proposed as an alternative
looking at it and launching tests