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

Pass user and password when connecting to server #48

Open
SamF111 opened this issue Sep 8, 2021 · 4 comments
Open

Pass user and password when connecting to server #48

SamF111 opened this issue Sep 8, 2021 · 4 comments
Labels
needs info More information is needed.

Comments

@SamF111
Copy link

SamF111 commented Sep 8, 2021

Hi,
I have hardcoded together a hack, but can the other connect() options be included:
ModelUtil.connect(<host>,<port>,<user>,<password>)

as an example.

@john-hen
Copy link
Collaborator

john-hen commented Sep 8, 2021

In principle, yes. I guess we could add optional arguments user and password to Client.__init__(), for example. But since I've never used remote client-server connections myself, may I ask: Why do you need this? When starting the server via an mph.Server instance, we request "auto-login", i.e. we pass the command-line option -login auto when starting comsolmphserver so that it shouldn't require login information (if it's properly set up). Why is this not enough in your use case?

@john-hen john-hen added the feature Proposal for a new feature. label Oct 7, 2021
@john-hen john-hen changed the title Request: Enable Server Username/Passwords Pass user and password when connecting to server Oct 7, 2021
@john-hen john-hen added needs info More information is needed. and removed feature Proposal for a new feature. labels Oct 8, 2021
@john-hen
Copy link
Collaborator

So I won't include this until someone provides a rationale for why this is useful.

As it stands, the test suite (of this library) tests local client–server connections. This works without ever providing user credentials, and it works out of the box even on a fresh Comsol installation. I like when things "just work".

There is certainly a case to be made for why this is needed for remote client–server connections. So somebody please make that case. Until then, let's not give people incentives to hard-code user credentials in their programs. Because that's how these things leak.

@kellerkillian
Copy link

Hey there,
First of all thanks for the amazing package. I was looking for a comsol api for python for ages, your code works great.

I might be able to weigh in here. I like to run my simulations on the server, while all the outputs and the good stuff just run locally on my laptop. I usually just forward a ssh tunnel from the mphserver running on the server and do the rest locally. This would be an application for a remote client-server connection.

@john-hen
Copy link
Collaborator

john-hen commented Jul 29, 2022

Hi Killian, thanks for chiming in.

The use case is clear to me though. I'm rather wondering why the -login auto command-line option, which I mentioned in the earlier comment and which MPh is invoking as it is, does not have the effect that you're looking for. Especially since you already have an SSH tunnel set up. As I understand it, then you're using your SSH credentials, and to the Comsol server you should look like an authenticated local user, and it should let you "log in auto"-matically, without providing a different set of user name and password.

I may misunderstand this completely though. I never had a chance to test this, and the Comsol documentation doesn't really explain what -login auto does. So if you say this cannot be avoided and we need this in the library, then that's good enough for me.

That being said, there's already a way to do it with the current library code, it's just not documented. (Intentionally. Though I had it in mind the last time I refactored this part of the code.) If I remember correctly, you skip mph.start() and instantiate mph.Client directly, but pass an empty host name (host=None or something). Then you have an "unconnected" client, on which you can call the Java method connect(host, port, user, password), i.e. client.java.connect(...) in Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info More information is needed.
Projects
None yet
Development

No branches or pull requests

3 participants