summaryrefslogtreecommitdiff
path: root/internal
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge branch 'id-refactor-test-helper' into 'main'Nick Thomas2021-07-142-32/+11
|\ \ | | | | | | | | | | | | Refactor testhelper.PrepareTestRootDir using t.Cleanup See merge request gitlab-org/gitlab-shell!493
| * | Refactor testhelper.PrepareTestRootDir using t.CleanupIgor Drozdov2021-07-142-32/+11
| |/
* | Merge branch 'change_log_format' into 'main'Patrick Bajao2021-07-131-1/+1
|\ \ | | | | | | | | | | | | Change default logging format to JSON See merge request gitlab-org/gitlab-shell!476
| * | changed filename extension to .log as json can operate on .log filelistout2021-05-261-1/+1
| | |
| * | changed the format of log file to json from textlistout2021-05-241-2/+2
| | |
* | | Fix the Geo SSH push proxy hangingValery Sizov2021-07-014-6/+74
| |/ |/| | | | | | | | | | | | | | | | | Geo SSH proxy push currently impossible when the only action that happens is branch removal. This fix works in a way that it waits for flush packet from git and then checks pkt lines to determine is pack data is expected. The thing is that git doesnt send pack data when only branch removal happens. Explanation is in https://gitlab.com/gitlab-org/gitlab/-/issues/330494
* | Adding a UTC converter and testGary Holtz2021-06-182-1/+38
| |
* | fix: upgrade of the gitaly dependencyPavlo Strokov2021-06-027-12/+12
| | | | | | | | | | | | | | | | | | | | | | Gitaly project now properly respects module release flow and includes a module suffix in the package name. It requires to re-write all non-suffixed imports with suffixed of a specific version of tha module. With proper module versioning we don't need to use a 'replace' directive to point to specific commit and can use semantic versioning for the gitaly dependency. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/3177
* | Unit test wrong channel typeIgor Drozdov2021-06-011-4/+34
| |
* | Merge branch '501-fix-opentracing-init' into 'main'Igor Drozdov2021-05-249-87/+105
|\ \ | |/ |/| | | | | | | | | Fix opentracing setup for gitlab-sshd Closes #501 See merge request gitlab-org/gitlab-shell!473
| * Fix opentracing setup for gitlab-sshdNick Thomas2021-05-179-87/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, opentracing (if configured) was initialized late in the gitlab-shell process's lifespan, coming just before making a gRPC call to Gitaly. By moving the opentracing initialization to be at process startup, we make it available for the whole process lifecycle, which is very useful to gitlab-sshd, as it means we'll only call tracing.Initialize() once on process startup, rather than once per SSH connection. To get this working, we need to introduce a context to gitlab-sshd. This carries the client/service name, but also carries an initial correlation ID. The main outcome of this is that all calls to the authorized_keys endpoint from a given gitlab-sshd process will now share a correlation ID. I don't have a strong opinion about this either way. Changelog: fixed
* | Add a simple acceptance test for git-receive-packSean McGivern2021-05-201-3/+3
| |
* | Add acceptance test for git-lfs-authenticateSean McGivern2021-05-171-0/+22
|/
* Merge branch '501-gitaly-respect-parent-context' into 'main'Nick Thomas2021-05-1013-41/+39
|\ | | | | | | | | Respect parent context for Gitaly calls See merge request gitlab-org/gitlab-shell!469
| * Respect parent context for Gitaly callsNick Thomas2021-05-0513-41/+39
| | | | | | | | | | | | | | | | | | Without these changes, Gitaly calls would not be linked to a parent context. This means that they would have an unassociated correlationID, and Gitaly RPC calls would not be cancel()ed by parent context cancellation. Changelog: fixed
* | Stop changing directory to the filesystem rootNick Thomas2021-05-061-6/+0
| | | | | | | | | | | | | | | | | | | | | | This behaviour dates from when Gitaly RPCs were executed in Ruby by a Go subprocess. It's not needed for gitlab-shell now that it's in Go, and it's a very strange thing for gitlab-sshd. Best just to remove it. If we wanted to retain this behaviour, we could have an `os.Chdir` call in the gitlab-shell binary, but I just don't think it's needed. Changelog: fixed
* | Merge branch '516-handle-ssl-cert-dir-correctly' into 'main'Nick Thomas2021-05-044-87/+94
|\ \ | | | | | | | | | | | | | | | | | | gitlab-sshd: Respect the ssl_cert_dir config Closes #516 See merge request gitlab-org/gitlab-shell!467
| * | gitlab-sshd: Respect the ssl_cert_dir config516-handle-ssl-cert-dir-correctlyNick Thomas2021-04-304-87/+94
| |/ | | | | | | Changelog: fixed
* | Don't finish the opentracing span earlydont-close-span-earlyNick Thomas2021-04-301-1/+0
|/ | | | | | | | | Calling finished() in `ContextWithCorrelationID` breaks opentracing, since it expects us to call it just before exiting, and this defer runs on function completion. All existing users of ContextWithCorrelationID already `defer finish()` themselves, so this call is entirely surplus to requirements.
* sshd: Recover from per-session and per-connection panics511-be-safe-against-panicsNick Thomas2021-04-233-3/+71
| | | | | | Without this, a failure in a single session could take out a whole connection, or a failure in a single connection could take out the whole server.
* Extract sshd connections and sessions into their own files and structsNick Thomas2021-04-233-175/+257
|
* gitlab-sshd: Support the PROXY protocolNick Thomas2021-04-122-3/+13
|
* Fix thread-safety issues in gitlab-shell518-fix-thread-safetyNick Thomas2021-04-092-23/+23
|
* Replace cleanup functions with t.CleanupIgor Drozdov2021-03-1724-129/+79
| | | | | In this case we don't need to propagate cleanup function. It simplifies the code.
* Merge branch '500-gitlab-sshd-acceptance-tests' into 'main'Igor Drozdov2021-03-171-0/+2
|\ | | | | | | | | gitlab-sshd: Acceptance test for the discover command See merge request gitlab-org/gitlab-shell!457
| * gitlab-sshd: Acceptance test for the discover commandNick Thomas2021-03-171-0/+2
| | | | | | | | | | With this, we can start to build confidence in making changes to gitlab-sshd.
* | chore: Refactor env introspection to rely on command initialization496-move-env-introspection-to-sshenvLucas Charles2021-03-1517-209/+200
|/ | | | | | | Refactors introspection of execution environment to rely on per-connection state (`gitlab-shell`) or per request (`gitlab-sshd`) Relates to https://gitlab.com/gitlab-org/gitlab-shell/-/issues/496
* Fix gitlab-shell panic when log file not writableStan Hu2021-02-262-2/+23
| | | | | | | | | Previously when the gitlab-shell log was not writable, gitlab-shell would attempt to fall back to the syslog to log an error. However, if the syslog logger creation succeeded, gitlab-shell would panic since `err` was `nil`. Relates to https://gitlab.com/gitlab-org/gitlab-shell/-/issues/510
* Use eventually to assert log entriesJaime Martinez2021-02-221-6/+11
|
* Add basic metrics to sshdbjk/monitoringBen Kochie2021-02-161-0/+48
| | | | | | | | | * Counter for how many times the max concurrent sessions limit was hit. * Histogram for duration of each SSH connection. https://gitlab.com/gitlab-org/gitlab-shell/-/issues/121 Signed-off-by: Ben Kochie <superq@gmail.com>
* Add monitoring endpoint to sshdBen Kochie2021-02-161-0/+2
| | | | | | | | | | | Add a basic monitoring endpoint to the sshd command. * Listen on localhost port 9122 by default. * Integrate build/version info. * Update example config. https://gitlab.com/gitlab-org/gitlab-shell/-/issues/121 Signed-off-by: Ben Kochie <superq@gmail.com>
* Refactor Config defaultsBen Kochie2021-02-161-50/+33
| | | | | | | | | | | Use "omitempty" to allow defaults in the config file to be correctly passed. Without this, explicitly setting an empty default like an empty string will not work. Needed in order to allow explicitly disabling some settings. Related to: https://gitlab.com/gitlab-org/gitlab-shell/-/issues/121 Signed-off-by: Ben Kochie <superq@gmail.com>
* Read limited input for yes answerIgor Drozdov2021-02-052-1/+12
|
* Remove session duration information from output of 2fa_verify command504-remove-the-session-duration-information-from-the-output-of-2fa_verify-commandManoj M J2021-01-292-2/+2
| | | | | This change removes session duration information from output of 2fa_verify command
* RFC: Simple built-in SSH serverLorenz Brun2021-01-1812-305/+376
|
* Add 2fa_verify commandImre Farkas2020-12-107-0/+434
|
* Include key ID and type in metadataAsh McKenzie2020-11-202-1/+8
|
* use testhelper for SSH_CONNECTIONclient-identityIgor Wiedler2020-11-191-5/+5
|
* test for client identity propagationIgor Wiedler2020-11-191-0/+63
|
* Propagate client identity to gitalyIgor Wiedler2020-11-171-0/+9
|
* GitLab API Client support for client certificatesPaul Okstad2020-11-172-0/+86
|
* Fix incorrect actor used to check permissions for SSH receive-packsh-fix-wrong-user-deploy-key-checkStan Hu2020-10-192-25/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | During a SSH receive-pack request (e.g. `git push`), gitlab-shell was incorrectly using the user returned by the `/internal/allowed` API endpoint to make an SSHReceivePack RPC call. This caused a number of problems with deploy keys with write access: 1. Keys that were generated by a blocked user would be denied the ability to write. 2. Keys that were generated by user that did not have write access to the project would also be denied. GitLab 12.4 removed the Ruby implementation of gitlab-shell in favor of the Golang implementation, and these implementations worked slightly differently. In https://gitlab.com/gitlab-org/gitlab-shell/blob/v10.1.0/lib/gitlab_shell.rb, the Ruby implementation would always use `@who` (e.g. `key-123`), but in gitlab-shell v10.2.0 the Go implementation would always use the user from the API response. Reads did not have this issue because the user/deploy key is never passed to Gitaly for additional permission checks. Writes need this information for the pre-receive to check access to protected branches, push rules, etc. Relates to https://gitlab.com/gitlab-org/gitlab-shell/-/issues/479
* Set SSL_CERT_DIR env var when building commandashmckenzie/set-ssl-cert-dir-env-varAsh McKenzie2020-10-192-46/+84
|
* Remove prefixing with SSL_CERT_DIRAsh McKenzie2020-10-194-73/+10
|
* tests: Replace assert with requirezj-remove-testify-assertZeger-Jan van de Weg2020-10-159-48/+40
| | | | | | | | | Testify features sub packages `assert` and `require`. The difference is subtle, and lost on novice Golang developers that don't read the docs. To create a more consistent code base `assert` will no longer be used. This change was generated by a running a sed command on all `_test.go` files, followed by `goimports -w`.
* Drop "generated random correlation ID" log messagesh-suppress-random-correlation-id-logStan Hu2020-10-131-1/+0
| | | | | | This message happens all the time and doesn't add a lot of value. Relates to https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1275
* Make it possible to propagate correlation ID across processesStan Hu2020-09-2044-121/+258
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, gitlab-shell did not pass a context through the application. Correlation IDs were generated down the call stack instead of passed around from the start execution. This has several potential downsides: 1. It's easier for programming mistakes to be made in future that lead to multiple correlation IDs being generated for a single request. 2. Correlation IDs cannot be passed in from upstream requests 3. Other advantages of context passing, such as distributed tracing is not possible. This commit changes the behavior: 1. Extract the correlation ID from the environment at the start of the application. 2. If no correlation ID exists, generate a random one. 3. Pass the correlation ID to the GitLabNet API requests. This change also enables other clients of GitLabNet (e.g. Gitaly) to pass along the correlation ID in the internal API requests (https://gitlab.com/gitlab-org/gitaly/-/issues/2725). Fixes https://gitlab.com/gitlab-org/gitlab-shell/-/issues/474
* Fix gitlab-shell not handling relative URLs over UNIX socketssh-fix-unix-relative-url-accessStan Hu2020-08-201-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/4498#note_397401883, if you specify a relative path such as: ``` external_url 'http://gitlab.example.com/gitlab' ``` gitlab-shell doesn't have a way to pass the `/gitlab` to the host. For example, let's say we have: ``` gitlab_url: "http+unix://%2Fvar%2Fopt%2Fgitlab%2Fgitlab-workhorse%2Fsocket" ``` If we have `/gitlab` as the relative path, how do we specify what is the UNIX socket path and what is the relative path? If we specify: ``` gitlab_url: "http+unix:///var/opt/gitlab/gitlab-workhorse.socket/gitlab ``` This is ambiguous. Is the socket in `/var/opt/gitlab/gitlab-workhorse.socket/gitlab` or in `/var/opt/gitlab/gitlab-workhorse.socket`? To fix this, this merge request adds an optional `gitlab_relative_url_root` config parameter: ``` gitlab_url: "http+unix://%2Fvar%2Fopt%2Fgitlab%2Fgitlab-workhorse%2Fsocket" gitlab_relative_url_root: /gitlab ``` This is only used with UNIX domain sockets to disambiguate the socket and base URL path. If `gitlab_url` uses `http://` or `https://`, then `gitlab_relative_url_root` is ignored. Relates to https://gitlab.com/gitlab-org/gitlab-shell/-/issues/476
* Add support obtaining personal access tokens via SSHTaylan Develioglu2020-08-177-6/+559
| | | | | | | | | | | | | | | | | | | | | | | | Implements the feature requested in gitlab-org/gitlab#19672 This requires the internal api counterpart in gitlab-org/gitlab!36302 to be merged first. It can be used as follows: ``` censored@censored-VirtualBox:~/git/gitlab$ ssh git@gitlab-2004 personal_access_token remote: remote: ======================================================================== remote: remote: Usage: personal_access_token <name> <scope1[,scope2,...]> [ttl_days] remote: remote: ======================================================================== remote: censored@censored-VirtualBox:~/git/gitlab$ ssh git@gitlab-2004 personal_access_token newtoken read_api,read_repository 30 Token: aAY1G3YPeemECgUvxuXY Scopes: read_api,read_repository Expires: 2020-08-07 ```
* Generate and log correlation IDsStan Hu2020-07-316-20/+36
| | | | | This will make it easier to tie an SSH access request to Rails API and Gitaly requests.