Credentials UI adds empty values
Nobody has claimed this yet.
- Dominant language
- Elixir
- Stars
- 296
- Forks
- 86
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 50
Description
When creating a credential in Lightning, values the user does not set can still end up generating a key on the config object.
In commcare, it just happens that this breaks authorisation and the credential doesn't work in some cases. Lightning generates a config object like this:
{
"username": "joe",
"password": "i-love-lightning",
"apikey": "",
}
To reproduce
- Open Lightning
- Create a commcare@2.0.0 credential
- Use any random values, but don't touch the apiKey field
- Save the credential
- Create a job which uses commcare and just does this:
fn((state) => {
console.log(state.data)
return state
})
You should see that the created credential sets apiKey to empty value, apiKey: "", even though we didn't ask for an API key
Adaptors note
This stuff probably doesn't usually matter, but it just so happens that commare does this:
if ('apiKey' in auth) {
Object.assign(headers, {
Authorization: `ApiKey ${auth.username}:${auth.apiKey}`,
});
} else if ('password' in auth) {
Object.assign(headers, makeBasicAuthHeader(auth.username, auth.password));
}
We could easily add a workaround in commcare to not use in. But I also think in is a reasonable pattern
The credential doesn't mark apiKey as required or set a default, so I don't know why this key gets set. Oh, it does set minLength, I don't know if that's part of the problem?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in Lightning by creating a commcare@2.0.0 credential without setting apiKey, then inspect credential creation and config generation. Done means omitted credential values are absent from the config object, so the commcare adaptor selects password authentication rather than an empty API key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100