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

feat: manage ssh keys for accounts #187

Merged
merged 103 commits into from
Dec 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
3e372cb
feat: add SecureAccessKeyName VO
polillomm Nov 21, 2024
01484e9
feat: add SecureAccessKeyContent VO
polillomm Nov 21, 2024
a7c7705
feat: add SecureAccessKey entity
polillomm Nov 21, 2024
ba295c9
feat: add HashId to SecureAccessKey entity
polillomm Nov 21, 2024
870eea9
feat: add ACCOUNT_SECURE_ACCESS_KEY_SECRET to auto generate env vars
polillomm Nov 21, 2024
441b3e1
feat: add SecureAccessKeyHashId VO
polillomm Nov 21, 2024
0bd9cf2
feat: implements SecureAccessKeyHashId VO as HashId type into SecureA…
polillomm Nov 21, 2024
48fba90
feat: add ReadSecureAccessKeys to AccountQueryRepo infra
polillomm Nov 22, 2024
984cc96
chore: merge pull request goinfinite#183
polillomm Nov 22, 2024
36ee4ed
refact: using ReadRequestBody API helper instead to create requestBod…
polillomm Nov 22, 2024
d6484e9
fix: ignoring EOF by checking if content is an empty string
polillomm Nov 22, 2024
b10442d
feat: add ReadAccountSecureAccessKeys use case
polillomm Nov 22, 2024
e25551e
feat: implements new get route to API and CLI to read account secure …
polillomm Nov 22, 2024
4aa99e9
refact: change HashId to Uuid and add encoded content to entity to re…
polillomm Nov 25, 2024
bc00375
feat: add CreateSecureAccessKey DTO
polillomm Nov 25, 2024
02837aa
refact: change error name when key content has no name
polillomm Nov 25, 2024
f96f175
refact: change keyId to uint16 instead uuid
polillomm Nov 25, 2024
150a377
feat: add CreateSecureAccessKey flow and implements new ensure method…
polillomm Nov 25, 2024
9b1e5ec
feat: implements ReadSecureAccessKeyByName and use in AccountCmdRepo
polillomm Nov 25, 2024
19fdee2
feat: implements activity record to CreateSecureAccessKey UC
polillomm Nov 25, 2024
3116bca
feat: implements secure access key creation to API and CLI
polillomm Nov 25, 2024
9ca1c62
feat: implements new secure access keys methods from AccountQueryRepo…
polillomm Nov 25, 2024
64c9dd5
chore: add .3 to Go version
polillomm Nov 25, 2024
b277ccf
feat: implements new secure access keys creation method from AccountC…
polillomm Nov 25, 2024
c678edc
feat: add DeleteSecureAccessKey DTO
polillomm Nov 25, 2024
7545e83
feat: add ReadSecureAccessKeyById to AccountQueryRepo
polillomm Nov 25, 2024
487c62c
feat: implements DeleteSecureAccessKey to CLI and API
polillomm Nov 25, 2024
9e14dbf
refact: remove accountId from CreateSecureAccessKey DTO JSON annotation
polillomm Nov 25, 2024
d6674bf
chore: update swagger
polillomm Nov 25, 2024
e82f88b
chore: update CreateSecureAccessKey swagger notation
polillomm Nov 25, 2024
b4e79fd
refact: using try catch to return GET responses instead to use callba…
polillomm Nov 26, 2024
3d7acce
feat: add empty structure to accounts page to show all secure access …
polillomm Nov 26, 2024
a6e69a7
feat: implements ssh dev build to install openssh and export port 22 …
polillomm Nov 27, 2024
7ff8797
feat imlements openssh service availability validation to create and …
polillomm Nov 27, 2024
4c6cc82
refact: fit all group inside the circular button component
polillomm Nov 27, 2024
eb45206
feat: add SecureAccessKeysList modal with delete secure access key im…
polillomm Nov 27, 2024
ba1cebc
chore: add "templ" as ignored cSpell word
polillomm Nov 27, 2024
208b081
refact: add margin right to create account button
polillomm Nov 28, 2024
19a24be
refact: remove readUsernameById
polillomm Nov 28, 2024
6a01bab
feat: implements allowAccountSecureRemoteConnection to accountCmdRepo
polillomm Nov 28, 2024
226eb7e
chore: merge pull request goinfinite#184
polillomm Nov 28, 2024
b59ff5d
feat: implements infoTooltipContent to TextArea component and turn pa…
polillomm Nov 28, 2024
d82481e
refact: split API router group to have accountGroup and secureAccessK…
polillomm Nov 28, 2024
abc40ac
refact: remove account secure access key security var from env vars
polillomm Nov 28, 2024
5234cc6
refact: move all secure access keys methods and implementation to you…
polillomm Nov 28, 2024
aa333c5
feat: implements new secure access key creation using database and fi…
polillomm Nov 28, 2024
fa8386c
refact: remove account existence validation from secure access key us…
polillomm Nov 28, 2024
c8c5f2b
feat: add SecureAccessKeyFingerprint
polillomm Nov 28, 2024
32ea2be
feat: implements pagination with new fingerprint prop
polillomm Nov 28, 2024
fd06538
fix: remove useless accountQueryRepo instance from secureAccessKeyQue…
polillomm Nov 28, 2024
7176b89
refact: change all secureAccessKeys and accounts infra, UC and presen…
polillomm Nov 29, 2024
d87b2cc
chore: update swagger
polillomm Nov 29, 2024
4fd6c78
feat: implements DTO to InputField component with InfoTooltipContent
polillomm Nov 29, 2024
b2a1918
feat: implements remove and creation secure access key
polillomm Nov 29, 2024
97dd21a
refact: get accounts with pagination on presenter
polillomm Nov 29, 2024
6ab3f4f
refact: add accountId to json tag
polillomm Nov 29, 2024
56536dc
refact: change create secure access key route swagger annotation
polillomm Nov 29, 2024
37c2d63
chore: update swagger
polillomm Nov 29, 2024
78f905c
refact: change params order to create DTO
polillomm Nov 29, 2024
6255e96
refact: remove secure access key validation and leave to fingerprint …
polillomm Nov 29, 2024
1ea90ed
refact: remove useless "Infra" from error message log
polillomm Nov 29, 2024
dfba008
refact: change params order to create DTO in infra tests
polillomm Nov 29, 2024
bba333f
refact: improve recreateSecureAccessKeysFile method
polillomm Nov 29, 2024
54d7928
fix: add space between keys elements and change open secure access ke…
polillomm Dec 2, 2024
6b6f646
refact: allow ed25519 as secureAccessKeyContent in addition to rsa
polillomm Dec 4, 2024
7170a13
fix: change system resource identifier to secure access key param fro…
polillomm Dec 4, 2024
6069fe6
refact: change "account" return var name to "accountEntity"
polillomm Dec 4, 2024
c7675a8
refact: change read fingerprint error message
polillomm Dec 4, 2024
20d2dd0
refact: creating account with /bin/bash as default shell instead to c…
polillomm Dec 4, 2024
960927d
refact: restore original additional.js
polillomm Dec 4, 2024
a276734
refact: change all names that includes "SecureAccessKey" to "SecureAc…
polillomm Dec 4, 2024
e86bd9b
chore: update CHANGELOG
polillomm Dec 4, 2024
ca4c9ce
refact: change all names that includes "SecureAccessKey" to "SecureAc…
polillomm Dec 4, 2024
c6806de
refact: change secureAccessPublicKeyName to ptr on entity and inject …
polillomm Dec 5, 2024
232942d
refact: change all names that includes "SecureAccessKey" to "SecureAc…
polillomm Dec 5, 2024
76f6b12
refact: move JSONScript to inside a <th>
polillomm Dec 5, 2024
61eb651
refact: merge secure access key infra and domain with account
polillomm Dec 5, 2024
886ce7d
chore: update swagger
polillomm Dec 5, 2024
3b5a242
refact: back to require key name instead to a ptr one
polillomm Dec 5, 2024
5f0364a
fix: pin unocss reset css
polillomm Dec 5, 2024
1876268
refact: change recreate authorized keys file method name to auto update
polillomm Dec 5, 2024
8c98a82
refact: change errors messages and var names to use ssh and authorize…
polillomm Dec 5, 2024
435150d
refact: add break line to additional.js
polillomm Dec 5, 2024
0b04887
refact: remove regex validation from SecureAccessPublicKeyContent and…
polillomm Dec 6, 2024
1343d1b
feat: add SecureAccessPublicKey entity test
polillomm Dec 6, 2024
68e0b1a
refact: return "AccountNotFound" instead infra error on use cases
polillomm Dec 6, 2024
5060576
feat: add fingerprint as key content metadata on VO
polillomm Dec 6, 2024
8d92548
refact: remove test and parsing from SecureAccessPublicKey that throw…
polillomm Dec 6, 2024
03e39e7
fix: merge pull request #192
polillomm Dec 6, 2024
fca2c16
refact: using entity sufix
polillomm Dec 9, 2024
0014feb
feat: implements HomeDirectory to Account entity and model with new i…
polillomm Dec 9, 2024
9270036
fix: add some prefixes and change some method names on account infra
polillomm Dec 9, 2024
2062e75
refact: change fk name on SecureAccessPublicKey model
polillomm Dec 9, 2024
6a758e1
refact: change param description on account API controller and update…
polillomm Dec 9, 2024
19e38ee
feat: implements comment header to authorizedKeys file warning user t…
polillomm Dec 9, 2024
a0b00d0
refact: change ReadAccounts command short description
polillomm Dec 9, 2024
8372348
refact: using strconv.Itoa instead FormatInt
polillomm Dec 9, 2024
9941002
refact: remove service validator from Account service layer
polillomm Dec 9, 2024
556a64c
fix: apply some changes to improve accounts legibility, descriptions …
polillomm Dec 9, 2024
8f724de
refact: change VO to unique string value and parser content again to …
polillomm Dec 9, 2024
fd83b18
fix: add "key" prefix to fingerprint var name
polillomm Dec 9, 2024
9e84891
refact: using homeDirectory var value instead hardcode
polillomm Dec 9, 2024
2d9fa18
refact: change SecureAccessPublicKeyName regex to avoid name that has…
polillomm Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add SecureAccessKeyName VO
polillomm committed Nov 21, 2024
commit 3e372cb6613f72098ede39d42f421b09374bb132
32 changes: 32 additions & 0 deletions src/domain/valueObject/secureAccessKeyName.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package valueObject

import (
"errors"
"regexp"

voHelper "github.com/goinfinite/os/src/domain/valueObject/helper"
)

const secureAccessKeyNameRegex string = `^[\w@\-_]{6,32}$`

type SecureAccessKeyName string

func NewSecureAccessKeyName(
value interface{},
) (keyName SecureAccessKeyName, err error) {
stringValue, err := voHelper.InterfaceToString(value)
if err != nil {
return keyName, errors.New("SecureAccessKeyNameMustBeString")
}

re := regexp.MustCompile(secureAccessKeyNameRegex)
if !re.MatchString(stringValue) {
return keyName, errors.New("InvalidSecureAccessKeyName")
}

return SecureAccessKeyName(stringValue), nil
}

func (vo SecureAccessKeyName) String() string {
return string(vo)
}
36 changes: 36 additions & 0 deletions src/domain/valueObject/secureAccessKeyName_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package valueObject

import (
"testing"
)

func TestSecureAccessKeyName(t *testing.T) {
t.Run("ValidSecureAccessKeyName", func(t *testing.T) {
rawValidSecureAccessKeyName := []interface{}{
"myMachine@pop-os", "thats-my-only-pc", "tryingWithThisTypeOfName",
}

for _, rawKeyName := range rawValidSecureAccessKeyName {
_, err := NewSecureAccessKeyName(rawKeyName)
if err != nil {
t.Errorf(
"Expected no error for '%v', got '%s'", rawKeyName, err.Error(),
)
}
}
})

t.Run("InvalidSecureAccessKeyName", func(t *testing.T) {
rawInvalidSecureAccessKeyName := []interface{}{
"", "that's not allowed, u know?", "maybe-with-#",
"thisIsAnEnormousNameToTestVoLength",
}

for _, rawKeyName := range rawInvalidSecureAccessKeyName {
_, err := NewSecureAccessKeyName(rawKeyName)
if err == nil {
t.Errorf("Expected error for '%v', got nil", rawKeyName)
}
}
})
}