-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Fix regression in writing authorized principals #36213
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
Fix regression in writing authorized principals #36213
Conversation
Commit ac6d38e introduced a regression in writing of the authorized_principals file, resulting in an empty file. The function `regeneratePrincipalsKeys` in `services/asymkey/ssh_key_authorized_principals.go` calls the function `WriteAuthorizedStringForValidKey` for a PublicKey of type KeyTypePrincipal, and ssh.ParseAuthorizedKey would always fail. This commit adds additional logic to this function to restore the previous behaviour when writing the principals file. Fixes: 36212 Signed-off-by: Peter Verraedt <peter.verraedt@kuleuven.be>
|
The Actually we don't really need to use |
|
Gitea is using sshd_config's AuthorizedPrincipalsFile option:
Specification of the accepted cert-authority is in the TrustedUserCAKeys file. The man pages are not really clear on which principals are accepted. Clearly no newlines could be present inside an allowed principal, but I'm not sure about spaces etc. |
|
Hmm ... I remembered wrong (I am not really a authorized_principals user). Can we have a regexp to validate the I can help to add more tests to cover the expected behaviors. |
|
Added a dummy regular expression. I'll try to find any references in sshd code to see what should be the actual expression. |
9632d2b to
6e29350
Compare
Signed-off-by: Peter Verraedt <peter.verraedt@kuleuven.be>
6e29350 to
00fe4b3
Compare
12988c2 to
5d26d16
Compare
|
Thank you very much, and I added some tests. |
Add additional logic with tests to restore the previous behaviour when writing the principals file. Fixes: go-gitea#36212 --------- Signed-off-by: Peter Verraedt <peter.verraedt@kuleuven.be> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* origin/main: Show edit page confirmation dialog on tree view file change (go-gitea#36130) Fix regression in writing authorized principals (go-gitea#36213) [skip ci] Updated translations via Crowdin Convert locale files from ini to json format (go-gitea#35489) Bump crowdin/github-action from 1 to 2 (go-gitea#36204) Bump appleboy/git-push-action from 0.0.3 to 1.0.0 (go-gitea#36194) Fix labeler config for stylelint (go-gitea#36199) Add `modifies/dependencies` label to dependabot (go-gitea#36206) Add date to "No Contributions" tooltip (go-gitea#36190) Revert "Bump alpine to 3.23 (go-gitea#36185)" (go-gitea#36202) Add JSON linting (go-gitea#36192) Bump setup-node to v6, re-enable cache (go-gitea#36207) [skip ci] Updated translations via Crowdin Update chroma to v2.21.1 (go-gitea#36201) Disable dependabot automatic labels (go-gitea#36203) Bump astral-sh/setup-uv from 6 to 7 (go-gitea#36198) Front port changelog (go-gitea#36193) Bump dev-hanz-ops/install-gh-cli-action from 0.1.0 to 0.2.1 (go-gitea#36195) Bump aws-actions/configure-aws-credentials from 4 to 5 (go-gitea#36196) Bump docker/build-push-action from 5 to 6 (go-gitea#36197)
Commit ac6d38e introduced a regression in writing of the authorized_principals file, resulting in an empty file.
The function
regeneratePrincipalsKeysinservices/asymkey/ssh_key_authorized_principals.gocalls the functionWriteAuthorizedStringForValidKeyfor a PublicKey of type KeyTypePrincipal, and ssh.ParseAuthorizedKey would always fail.This commit adds additional logic to this function to restore the previous behaviour when writing the principals file.
Fixes: #36212