add charset modifier to secret generation #521
Labels
Clear labels
bug
build
ci/cd
critical fix
design
documentation
duplicate
easy-first-issue
enhancement
help wanted
i10n
i18n
installer
invalid
question
release
release-candidate
security
tech-debt
test
wontfix
Something is not working
go build related issues
Building things with CI/CD
https://docs.coopcloud.tech/federation/resolutions/passed/010/
UI/UX
Documenting all the things
This issue or pull request already exists
Something for new people to get stuck into. We hope it's easy!
New feature
Need some help
Everything to do with localisation
Everything to do with internationalisation
Everything to do with the install script.
Something is wrong
More information is needed
Release management
Related to the new release candidate
Security related
Unit/integration testing
This won't be fixed
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
abra v0.10.0
Done
Assignees
3wordchant
aadil (Aadil Ayub)
abra-bot (Abra Bot)
ammaratef45
amras (Sarma)
Apfelwurm
BornDeleuze
Brooke
carla
cas (Cassowary)
coopcloud
cyrnel
decentral1se (d1)
dede
devydave
fauno (fauno)
iexos
jade (Jade Ambrose)
jjsfunhouse
jmakdah2 (Jackie Makdah)
joe-irving (Joe Irving)
kawaiipunk (KawaiiPunk)
knoflook
kolaente
lambdabundesverband
linnealovespie (April)
moosemower
moritz
notplants
oxaliq (sorrel)
p4u1
pharaohgraphy (Andrew 🐦🔥❤️🔥✴️)
renovate-bot (Comrade Renovate Bot)
ripclap
simon
sixsmith (Sixsmith)
stevensting
trav (Trav Fryer)
val (val (he/him))
yksflip
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: toolshed/abra#521
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
since we need special chars in passwords for a recipe we are working on, i have added the option to specify a charset in the same way as the length can be setted.
i did not change anything in the behaviour, so if length is not specified, the charset gets ignored whether it is there or not.
you can specify the following:
charset=default- Results in passgen.AlphabetDefault being usedcharset=special- Results in passgen.AlphabetSpecial being usedcharset=safespecial- Results in!@#%^&*_-+=being used (so it is AlphabetSpecial without the dollar sign)charset=default,specialorcharset=special,default- Results in passgen.AlphabetDefault + passgen.AlphabetSpecial being usedcharset=default,safespecialorcharset=safespecial,default- Results in passgen.AlphabetDefault +!@#%^&*_-+=being used ((so it is AlphabetSpecial without the dollar sign)Also added the charset testing to TestReadSecretsConfig. I thought about implementing tests for the generation itself, but did not really come up with something that made sense for me.
As i'm not that familiar with go, this might need to be reviewed carefully and might need additional work.
Edit: PR for the docs: toolshed/docs.coopcloud.tech#271
@@ -45,3 +49,3 @@// GeneratePasswords generates passwords.func GeneratePasswords(count, length uint) ([]string, error) {func GeneratePasswords(count, length uint, charset string) ([]string, error) {I think GeneratePasswords is only used with
count=1. If you are up for it, a seperate refactor commit would be nice, that changes the function toGeneratePassword(length uint, charset string) (string, error)(Same for
GeneratePassphrases)done :)
@@ -152,1 +156,4 @@}charset := modifierValues["charset"]value.Charset = resolveCharset(charset)This can be combined into one line
Is
"charset"guaranteed to be present? Otherwise, you might want to do the presence check of the key and otherwise supply a default.It retuens an empty string when not present, which is handled in
resolveCharset. SO for me its fine to not check for the presencedone :)
Really Cool ™
4795c4d732tod3c9c39f13@@ -61,3 +65,3 @@// GeneratePassphrases generates human readable and rememberable passphrases.func GeneratePassphrases(count uint) ([]string, error) {func GeneratePassphrases() ([]string, error) {the return type could also be changed to
(string, error)done, also changed the name to fit the single generation
@@ -44,11 +48,11 @@ type Secret struct {}// GeneratePasswords generates passwords.func GeneratePasswords(count, length uint) ([]string, error) {the return type could also be changed to
(string, error)done, also changed the name to fit the single generation
ad032bb89ctob7d957877a