Question

Is there a way of setting the SmalltalkHub username and password in an environment variable or an external configuration file as opposed to setting them in every repository in every image? It gets old introducing them always.

Was it helpful?

Solution

This is the solution I eventually found.

The MCHTTPRepository>>userAndPasswordFromSettingsDo: already has machinery for using credentials. It looks them up in the MCRepository.Settings class variable where it expects to find a Dictionary. Unfortunately that class variable is never set nor referenced anywhere in the image. There is also no accessor for it.

Thus, we patch the class with an accessor method for Settings and then set the account information in a startup script:

StartupLoader default executeAtomicItems: {
    StartupAction 
        name: 'Accounts'  
        code: [ 
               Author fullName: 'AuthorName'.
               MCRepository class compile: 'settings ^Settings ifNil: [ Settings := Dictionary new.]'.
               MCRepository settings 
                   at: 'account1' 
                   put: '*smalltalkhub.com* username:password'  ]
        runOnce: true
}

As in @Uko's example, the script should be in in ~/Library/Preferences/pharo.

OTHER TIPS

Ciao Mircea

So to set your Author name you can use personal.st script from my gist available here.

If you want to set up your credentials, you should create a similar startup action with:

MCRepositoryGroup default repositories
  select: [:each |
    (each isKindOf: MCHttpRepository) and:
    [each location includesSubstring: 'smalltalkhub.com' ]]
  thenDo: [ :repo |
    repo
      user: 'your_user_name';
      password: 'your_secret_password' ]

It would also be nice to have one feature to actually remove all of those credentials. This is useful when shipping images to other people so that there are no passwords in there.

Also, there is a side thing, which is that the changes file may have some passwords in it. I am curious to know how this could be handled.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top