FTP repo without storing username/pass in ConfigurationOf

5 views
Skip to first unread message

Mariano Martinez Peck

unread,
Apr 15, 2013, 2:11:09 PM4/15/13
to meta...@googlegroups.com, Pharo Development
Hi all,

I have the code of an app in a FTP repo which has username/password. 
I am doing a ConfigurationOfMyApp now and I would need to define in the baseline something like 

spec repository: 'ftp.mydomainapp.com ...etc'.

I know I have a similar method for also specifying the username/pass. But I don't want that because it means storing the username/pass in the ConfigurationOf code. 

So....how can I manage this with metacello? the only thing I found (which I am not sure if it works) is to use repositoryOverride so when I am about to load my project I do a #repositoryOverride: passing as argument a FTP with my username/password. 

What do you think?

best, 

Dale Henrichs

unread,
Apr 15, 2013, 8:07:56 PM4/15/13
to meta...@googlegroups.com, Pharo Development
Mariano,

I would think that you'd treat the FTP repository like the HTTP repository, i.e., if you add the repository in the MetacelloBrowser and set the username/password there, then Metacello should honor that (like it does for the HTTP repository) ... so instead of adding some sort of repository override to the load script, simply create the FTP repository with username/password inline in your load script.

Dale
| --
| You received this message because you are subscribed to the Google Groups
| "Metacello" group.
| To unsubscribe from this group and stop receiving emails from it, send an
| email to metacello+...@googlegroups.com.
| For more options, visit https://groups.google.com/groups/opt_out.
|
|
|

Mariano Martinez Peck

unread,
Apr 15, 2013, 9:02:03 PM4/15/13
to meta...@googlegroups.com
On Mon, Apr 15, 2013 at 9:07 PM, Dale Henrichs <dhen...@vmware.com> wrote:
Mariano,

I would think that you'd treat the FTP repository like the HTTP repository, i.e., if you add the repository in the MetacelloBrowser

Dale, do you mean MonticelloBrowser rather than MetacelloBrowser? In either case, I was not using any of them....I was thinking of how to load my app with metacello using a Gofer script. 
 
and set the username/password there, then Metacello should honor that (like it does for the HTTP repository) ... so instead of adding some sort of repository override to the load script, simply create the FTP repository with username/password inline in your load script.


Do you mean that I should declare my FTP repository like:

MCFtpRepository
  host: 'ftp.xxx.com'
  directory: 'mc'
  user: aUsername
  password: aPassword

and somehow register that repo in Monticello ?  so then when I load a ConfiguratioOfMyApp that has that repo it will honor the already set up username/password?

Thanks!

 

Dale Henrichs

unread,
Apr 15, 2013, 9:14:00 PM4/15/13
to meta...@googlegroups.com


----- Original Message -----
| From: "Mariano Martinez Peck" <maria...@gmail.com>
| To: meta...@googlegroups.com
| Sent: Monday, April 15, 2013 6:02:03 PM
| Subject: Re: [Metacello] FTP repo without storing username/pass in ConfigurationOf
|
| On Mon, Apr 15, 2013 at 9:07 PM, Dale Henrichs <dhen...@vmware.com> wrote:
|
| > Mariano,
| >
| > I would think that you'd treat the FTP repository like the HTTP
| > repository, i.e., if you add the repository in the MetacelloBrowser
|
|
| Dale, do you mean MonticelloBrowser rather than MetacelloBrowser? In either
| case, I was not using any of them....I was thinking of how to load my app
| with metacello using a Gofer script.

Whoops yes, I meant MonticelloBrowser:)

|
|
| > and set the username/password there, then Metacello should honor that
| > (like it does for the HTTP repository) ... so instead of adding some sort
| > of repository override to the load script, simply create the FTP repository
| > with username/password inline in your load script.
| >
|
|
| Do you mean that I should declare my FTP repository like:
|
| MCFtpRepository
| host: 'ftp.xxx.com'
| directory: 'mc'
| user: aUsername
| password: aPassword
|
| and somehow register that repo in Monticello ? so then when I load a
| ConfiguratioOfMyApp that has that repo it will honor the already set up
| username/password?

Yes. Metacello will use existing http/ftp/etc. repositories thus inheriting the username and passwords set in the image. So if you create the ftp repository ahead of time (and specify a username and password) everything should work smoothly (barring any bugs in Metacello:) ..

I think it is a good idea to try to keep Metacello out of the username/password business as much as possible:)

Dale

Mariano Martinez Peck

unread,
Apr 16, 2013, 10:55:50 AM4/16/13
to meta...@googlegroups.com
On Mon, Apr 15, 2013 at 10:14 PM, Dale Henrichs <dhen...@vmware.com> wrote:


|
|
| > and set the username/password there, then Metacello should honor that
| > (like it does for the HTTP repository) ... so instead of adding some sort
| > of repository override to the load script, simply create the FTP repository
| > with username/password inline in your load script.
| >
|
|
| Do you mean that I should declare my FTP repository like:
|
| MCFtpRepository
|   host: 'ftp.xxx.com'
|   directory: 'mc'
|   user: aUsername
|   password: aPassword
|
| and somehow register that repo in Monticello ?  so then when I load a
| ConfiguratioOfMyApp that has that repo it will honor the already set up
| username/password?

Yes. Metacello will use existing http/ftp/etc. repositories thus inheriting the username and passwords set in the image. So if you create the ftp repository ahead of time (and specify a username and password) everything should work smoothly (barring any bugs in Metacello:) ..

I think it is a good idea to try to keep Metacello out of the username/password business as much as possible:)


Hi Dale, I tried that but it still didn't work. I get the following error:

[:response | (TelnetProtocolError protocolInstance: self)
signal: response] in FTPClient(TelnetProtocolClient)>>lookForCode:
Receiver: a FTPClient
Arguments and temporary variables: 
code: 331
response: '530 This is a private system - No anonymous login'


In the baseline I have something like

         spec repository: 'ftp://ftp.mydomain.com/myDirectory'.    


and before loading with metacello I do:


repository := MCFtpRepository
  host: 'ftp.mydomain.com'
directory: 'myDirectory'
user: 'whatever'
password: 'whatelse'.

MCRepositoryGroup default addRepository: repository.

And in fact, if I open MonticelloBrowser I do see my FTP repo with its correct username/pass...I can browse packages etc...

So maybe I am not registering the package in the exact same collection Metacello is looking for? where does it look for the repo? 
how does it "honor" the already set up username/pass?

Thanks!


 
Dale

--
You received this message because you are subscribed to the Google Groups "Metacello" group.
To unsubscribe from this group and stop receiving emails from it, send an email to metacello+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Dale Henrichs

unread,
Apr 16, 2013, 1:06:52 PM4/16/13
to meta...@googlegroups.com
Mariano,

This sounds like a Metacello bug ... I know that the same trick works for HTTP repositories ... what version of Pharo are you using ... I'll have to track this one down ...

Dale

----- Original Message -----
| From: "Mariano Martinez Peck" <maria...@gmail.com>
| To: meta...@googlegroups.com
| Sent: Tuesday, April 16, 2013 7:55:50 AM
| Subject: Re: [Metacello] FTP repo without storing username/pass in ConfigurationOf
|

Dale Henrichs

unread,
Apr 16, 2013, 2:47:35 PM4/16/13
to meta...@googlegroups.com
Mariano,

After closer inspection it turns out that for FTP repositories, you must specify the username to uniquely identify the FTP url. If you specify the username and leave the password empty in your Metacello spec, things should work correctly ...

Here are the gory details.

There is code in Metacello that looks like the following:

description := aSpec description.
(repo := repositories
detect: [:rep | rep description = description ]
ifNone: [ aSpec createRepository ]) ~~ nil
ifTrue: [ repos add: repo ]

where Metacello is attempting to determine if the repository has already been created in the image. If the repository exists, then the in-image credentials are used and you don't have to include user and password in the Metacello repository spec.

BTW, if you look at MCRepository>>= Metacello is basically using the same algorithm.

Now if you look at how MCHttpRepository behaves:

(MCHttpRepository
location: 'http://example.com'
user: 'foo'
password: 'bar') description.

prints as:

'http://example.com'

Notice that the user is excluded from the description.

Whereas for MCFtpRepository behaves differently:

(MCFtpRepository
host: 'ftp.mydomain.com'
directory: 'myDirectory'
user: 'whatever'
password: 'whatelse') description.

prints as:

'ftp://what...@ftp.mydomain.com/myDirectory',

Notice that the `user` is included in the description...

So if you want an FTP repository to be considered #= to another FTP repository you must specify the user name ...

Let me know if this works for you.

Dale

----- Original Message -----
| From: "Mariano Martinez Peck" <maria...@gmail.com>
| To: meta...@googlegroups.com
| Sent: Tuesday, April 16, 2013 7:55:50 AM
| Subject: Re: [Metacello] FTP repo without storing username/pass in ConfigurationOf
|

Mariano Martinez Peck

unread,
Apr 16, 2013, 3:35:18 PM4/16/13
to meta...@googlegroups.com
On Tue, Apr 16, 2013 at 3:47 PM, Dale Henrichs <dhen...@vmware.com> wrote:
Mariano,

After closer inspection it turns out that for FTP repositories, you must specify the username to uniquely identify the FTP url. If you specify the username and leave the password empty in your Metacello spec, things should work correctly ...


Hi Dale,

Thanks for the gory details, I understood :)
Now I wonder...imagine I don't want to even include the username in the ConfigurationOf....  shouldn't the repository override trick work?
Something along the lines of:

| repository |
repository := MCFtpRepository
  host: 'ftp.mydomain.com'
directory: 'myDirectory'
user: 'whatever'
password: 'whatelse'.
version := (ConfigurationOfXX project version: 'xxx').
version 
repositoryOverrides: Array with: repository.
version load. 

just to be sure...#repositoryOverrides: does not propagate to transitive dependencies right?

Thanks in advance, 

Dale Henrichs

unread,
Apr 16, 2013, 5:13:15 PM4/16/13
to meta...@googlegroups.com
Mariano,

repositorOverrides: does apply to the entire load sequence, so it's not the best option for trying to simply keep your credentials private ...

The http repository does not expose user names and works just fine picking up the image based instance with credentials defined so I would expect the ftp repository to behave similarly.

If you want to keep the ftp user private the long term answer is submit a bug against the ftp repository implementation and ask that ftp repositories behave the same as http repositories with respect to credentials.

Like I said before, I don't think that Metacello should be in the business of managing credentials and that includes adding features to Metacello whose sole purpose is to make up for a deficiencies elsewhere in the system ...

For the short term, you might just change the definition of MCFtpRepository>>description from:

description
^ 'ftp://', user, '@', host, '/', directory

to:

description
^ 'ftp://', host, '/', directory

and your username can be kept private ... I doesn't appear that description is used for anything other than display and comparison purposes ...

Ben Coman

unread,
Apr 16, 2013, 8:24:59 PM4/16/13
to meta...@googlegroups.com
Dale Henrichs wrote:
> Mariano,
>
> repositorOverrides: does apply to the entire load sequence, so it's not the best option for trying to simply keep your credentials private ...
>
> The http repository does not expose user names and works just fine picking up the image based instance with credentials defined so I would expect the ftp repository to behave similarly.
>
> If you want to keep the ftp user private the long term answer is submit a bug against the ftp repository implementation and ask that ftp repositories behave the same as http repositories with respect to credentials.
>
+1 Principal Of Least Surprise.

Mariano Martinez Peck

unread,
Apr 17, 2013, 1:05:42 PM4/17/13
to meta...@googlegroups.com, Pharo Development
On Tue, Apr 16, 2013 at 6:13 PM, Dale Henrichs <dhen...@vmware.com> wrote:
Mariano,

repositorOverrides: does apply to the entire load sequence, so it's not the best option for trying to simply keep your credentials private ...


OK.
 
The http repository does not expose user names and works just fine picking up the image based instance with credentials defined so I would expect the ftp repository to behave similarly.

+9999
 

If you want to keep the ftp user private the long term answer is submit a bug against the ftp repository implementation and ask that ftp repositories behave the same as http repositories with respect to credentials.

+1
 

Like I said before, I don't think that Metacello should be in the business of managing credentials and that includes adding features to Metacello whose sole purpose is to make up for a deficiencies elsewhere in the system ...

For the short term, you might just change the definition of MCFtpRepository>>description from:

  description
        ^ 'ftp://', user, '@', host, '/', directory

to:

  description
        ^ 'ftp://', host, '/', directory

and your username can be kept private ... I doesn't appear that description is used for anything other than display and comparison purposes ...


Yes, this is a very good idea.
I will open an issue in the bug tracker.
Anyone has an objection?

Cheers,

Mariano Martinez Peck

unread,
Jun 3, 2013, 4:13:09 PM6/3/13
to meta...@googlegroups.com
Hi Dale,

Coming back to this problem. I am now using my own instance of SmalltalkHub running with HTTPS. And I have the same problem...
If I previously add the repository in the MonticelloBrowser, then the username/pass is "remembered" and it works.
But I am trying to define a load script without UI.

| repository |

repository := (MCHttpRepository
user: 'user'
password: 'pass').

MCRepositoryGroup default addRepository: repository.

But it seems that is not enough....mmmm what else can MonticelloBrowser do besides that??
mmmm browing MonticelloBrowser now to see if I find the answer....

best, 

Dale K. Henrichs

unread,
Jun 3, 2013, 5:28:46 PM6/3/13
to meta...@googlegroups.com
Mariano,

MCRepositoryGroup>>addRepository does a detect to see if the repo is already there and #= uses #description which does not include a #user or #password ... so the #addRepository is a noop if the repository is already defined ... so something like this is probably needed:

  | repository repo|

  repository := (MCHttpRepository
user: ''
password: '').
  repo := MCRepositorygroup default repositories detect: [:each | each description = repository description ] ifNone: [repository].
  repo
user: 'user';
password: 'pass'.

Then you can be guaranteed to set the user and password of the correct instance...

Dale


Reply all
Reply to author
Forward
0 new messages