summaryrefslogtreecommitdiff
path: root/internal
Commit message (Collapse)AuthorAgeFilesLines
* Draft: Kerberos changes for testing purposesIgor Drozdov2022-11-2413-39/+332
|
* Merge branch 'id-add-sshd-dev-docs' into 'main'Ash McKenzie2022-11-242-0/+48
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Add developer documentation to sshd package See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/683 Merged-by: Ash McKenzie <amckenzie@gitlab.com> Approved-by: Alejandro Rodríguez <alejandro@gitlab.com> Approved-by: Oscar Tovar <otovar@gitlab.com> Approved-by: James Fargher <proglottis@gmail.com> Approved-by: John Cai <jcai@gitlab.com> Approved-by: Amy Qualls <aqualls@gitlab.com> Approved-by: Ash McKenzie <amckenzie@gitlab.com> Co-authored-by: Igor Drozdov <idrozdov@gitlab.com>
| * Add developer documentation to sshd packageIgor Drozdov2022-11-232-0/+48
| |
* | sshd: Return error when proxy policy is misconfiguredJames Fargher2022-11-231-7/+12
| | | | | | | | | | MustStrictWhiteListPolicy panics when configured incorrectly. So here we use the error returning version instead.
* | sshd: Add ProxyAllowed setting to limit PROXY protocol IP addressesJames Fargher2022-11-233-6/+66
| | | | | | | | Changelog: added
* | sshd: Extract static proxy policy handlerJames Fargher2022-11-231-7/+13
| | | | | | | | | | | | | | Instead of interpreting the configuration for every new connection, we can rely on a closure to simplify the proxy handler path. This is more similar to how the provided MustStrictWhiteListPolicy works which will be added in a later commit.
* | Fix broken Gitaly integration testsPatrick Bajao2022-11-231-2/+2
|/ | | | | | | | | | | Gitaly started to require `Repository` information for certain commands like upload-pack, upload-archive, and receive-pack. However, gitlab-shell tests are sending `git_object_directory` and `git_alternate_object_directories` that do not exist. To fix the tests, we set those to an existing directory in the created repository.
* Improve error message for Gitaly `LimitError`sAlejandro Rodríguez2022-10-242-1/+50
|
* Merge branch 'id-add-documentation-to-command' into 'main'Patrick Bajao2022-09-211-0/+30
|\ | | | | | | | | | | | | | | | | Add developer documentation to command package See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/594 Merged-by: Patrick Bajao <ebajao@gitlab.com> Approved-by: Patrick Bajao <ebajao@gitlab.com> Co-authored-by: Igor Drozdov <idrozdov@gitlab.com>
| * Specify all packages that use commandsPatrick Bajao2022-08-031-1/+5
| |
| * Add developer documentation to command packageIgor Drozdov2022-08-031-0/+26
| |
* | Update Gitaly to v15Igor Drozdov2022-08-058-13/+13
|/ | | | | | | | | | | This commit also excludes gitlab-shell from dependencies: Gitaly specifies Gitlab Shell as a dependency as well in order to use gitlabnet client to perform API endpoints to Gitlab Rails. As a result, Gitlab Shell requires Gitaly -> Gitaly requires an older version of Gitlab Shell -> that version requires an older version of Gitlab Shell, etc. Let's use exclude to break the chain earlier
* Simplify 2FA Push auth processingIgor Drozdov2022-07-208-707/+448
| | | | Use a single channel to handle both Push Auth and OTP results
* Implement Push Auth support for 2FA verificationkmcknight2022-07-186-59/+484
| | | | | | | | | | | | | | | | | When `2fa_verify` command is executed: - A user is asked to enter OTP - A blocking call for push auth is performed Then: - If the push auth request fails, the user is still able to enter OTP - If OTP is invalid, the `2fa_verify` command ends the execution - If OTP is valid or push auth request succeeded, then the user is successfully authenticated - If 30 seconds passed while no OTP or Push have been provided, then the `2fa_verify` command ends the execution
* Fix flaky race testStan Hu2022-07-141-1/+2
| | | | | | | | `ignoredError.err` was being used in a Goroutine handler, but the value of `ignoredError` changes with each test case. To avoid a race, make a local copy of the error before each Goroutine runs. Closes https://gitlab.com/gitlab-org/gitlab-shell/-/issues/590
* go: Bump major version to v14Patrick Steinhardt2022-07-0573-271/+271
| | | | | | | | | | | | | While gitlab-shell currently has a major version of v14, the module path it exposes is not using that major version like it is required by the Go standard. This makes it impossible for dependents to import gitlab-shell as a dependency without using a commit as version. Fix this by changing the module path of gitlab-shell to instead be `gitlab.com/gitlab-org/gitlab-shell/v14` and adjust all imports accordingly. Changelog: fixed
* Pass original IP from PROXY requests to internal API callsAlejandro Rodríguez2022-06-304-20/+46
|
* gitlab-sshd: Add support for configuring host certificatesStan Hu2022-06-2611-8/+187
| | | | | | | | | | | | | | | | | This adds support for specifying host certificates via the `host_cert_files` option and advertises the signed key to the client. This acts similarly to OpenSSH's `HostCertificate` parameter: gitlab-sshd attempts to match a host key to its certificate, and then substitutes the matching host key with a certificate signed by a trusted certificate authority's key. This is the first requirement to supporting SSH certificates. This will enable the client to trust the server if both trust a common certificate authority. The `TrustedUserCAKeys` option will need to be supported later for the server to trust all user keys signed by this certificate authority. Relates to https://gitlab.com/gitlab-org/gitlab-shell/-/issues/495
* Ignore "not our ref" errors from gitlab-sshd error metricsStan Hu2022-06-062-1/+7
| | | | | | | | | | | | If a client requests a ref that cannot be found in the repository, previously gitlab-sshd would record it as part of its service level indicator metric. This is really an application error between the client and the Git repository, so we exclude it from our metrics. Relates to https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/15848 Changelog: fixed
* Exclude disallowed command from error rateIgor Drozdov2022-06-012-26/+26
|
* Calculate session start after the connection is establishedIgor Drozdov2022-05-251-2/+1
|
* Merge branch 'id-session-duration' into 'main'Stan Hu2022-05-253-19/+20
|\ | | | | | | | | Improve establish session duration metrics See merge request gitlab-org/gitlab-shell!651
| * Improve establish session duration metricsIgor Drozdov2022-05-253-19/+20
| | | | | | | | | | | | | | | | | | Before we took into account the time a user takes to authenticate Now it only measures the time between a connection established and a command started to being executed It's still can be controlled by a user, but it's something we can measure and restrict if necessary
* | Log gitlab-sshd session level indicator errorsStan Hu2022-05-241-2/+4
|/ | | | | | In production, we saw gitlab-sshd error metrics rise, but it was not clear why. We now log a message every time we encounter a session error that affects the service level indicator counter.
* Add missing SshdSessionEstablishedDuration metricsIgor Drozdov2022-05-231-0/+1
|
* Abort long-running unauthenticated SSH connectionsIgor Drozdov2022-05-234-11/+50
| | | | | | | | | The config option is basically a copy of LoginGraceTime OpenSSH option. If an SSH connection is hanging unauthenticated, after some period of time, the connection gets canceled. The value is configurable, the server waits for 60 seconds by default.
* Close the connection when context is canceledIgor Drozdov2022-05-232-6/+43
| | | | | | | | | | | When graceful shutdown timeout expires, the global context is canceled. All the operations dependent on it are canceled as well. Unfortunately, some of the operations doesn't respect the context. For example, SSH connection initialization. In this case, we need to manually close the connection. One of the options is to wait for ctx.Done() and close the connection
* Move connection init into connection.goIgor Drozdov2022-05-233-69/+78
|
* Return support for diffie-hellman-group14-sha1Igor Drozdov2022-05-231-0/+1
| | | | | It seems that a lot of users rely on this, let's return it and deprecated later to make the migration less disruptive
* Downgrade auth EOF messages from warning to debugIgor Drozdov2022-05-211-1/+1
| | | | | The errors happen when a client closes a connection on handshake They can be ignored to avoid noise
* Exclude Gitaly unavailable error from error rateIgor Drozdov2022-05-214-24/+26
| | | | | | | When a user hits repository rate limit, Gitaly returns an error that the request can't be handled (Gitaly unavailable) We should avoid this error to avoid exceeding the error rate
* Display constistently in gitlab-sshd and gitlab-shellIgor Drozdov2022-05-214-18/+31
| | | | | - Use console package to format the errors in gitlab-sshd - Suppress internal Gitaly errors in client output
* Merge branch 'sh-downgrade-host-key-errors' into 'main'Igor Drozdov2022-05-211-2/+15
|\ | | | | | | | | Downgrade host key mismatch messages from warning to debug See merge request gitlab-org/gitlab-shell!639
| * Downgrade handleConn start message to debugStan Hu2022-05-201-1/+1
| | | | | | | | This message doesn't provide that much value, so let's just drop it.
| * Downgrade host key mismatch messages from warning to debugStan Hu2022-05-201-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In production, we often see SSH key scans requesting host key algorithms that we don't support, such as `sk-ssh-ed25519@openssh.com` or `sk-ecdsa-sha2-nistp256@openssh.com`. These messages might be useful if someone forgets to configure a host key that should be supported, but most of the time they are noise. This commit downgrades these messages to DEBUG. Relates to https://gitlab.com/gitlab-org/gitlab-shell/-/issues/581 Changelog: changed
* | Introduce a GitLab-SSHD server version during handshakeHendrik Meyer2022-05-211-0/+1
|/
* Narrow supported kex algorithmsIgor Drozdov2022-05-202-19/+22
| | | | | | We don't support diffie-hellman-group14-sha1 via OpenSSH currently Let's avoid introducing it in gitlab-sshd because it's using weak hashing algorithm
* Make ProxyHeaderTimeout configurableIgor Drozdov2022-05-194-8/+11
| | | | | | | | Issue: https://gitlab.com/gitlab-org/gitlab-shell/-/issues/576 ProxyHeaderTimeout must be small to avoid DoS risk Let's make the value configurable and 500ms by default
* Allow specifying formatted durations in configIgor Drozdov2022-05-196-29/+74
| | | | | - If an integer is specified, we assume that these are seconds - A duration of format "500ms", "10s", "1m", etc... accepted
* Allow configuring SSH server algorithmsIgor Drozdov2022-05-193-0/+86
| | | | | MACs, Ciphers and KEX algorithms now can be configured If the values are empty, reasonable defaults are used
* Exclude API errors from error rateIgor Drozdov2022-05-182-1/+17
| | | | | | When API isn't responsible or the resource is not accessible (returns 404 or 403), then we shouldn't consider it as an error on gitlab-sshd side
* Log canceled requests into separate metricsIgor Drozdov2022-05-174-2/+53
| | | | When a request get canceled we don't want to consider it an error
* Wait until all Gitaly sessions are executedIgor Drozdov2022-05-172-6/+15
| | | | | | | | | | | | | | | | | If they haven't been executed within a timeout, we unblock the execution. Issue: https://gitlab.com/gitlab-org/gitlab-shell/-/issues/563 We have an issue when a lot of git clones operations get canceled. It was assumed that some clients close the connection just after all the data has been received from Git server. If there was a network delay and gitlab-sshd hadn't managed to gracefully close the connection, context get canceled and Gitaly cancels the execution and returns the error. Let's wait for a perion to allow Gitaly to gracefully complete the operation
* Return error from session handlerIgor Drozdov2022-05-165-63/+96
|
* Implement ClientKeepAlive optionIgor Drozdov2022-05-125-19/+95
| | | | | | | | | | Git clients sometimes open a connection and leave it idling, like when compressing objects. Settings like timeout client in HAProxy might cause these idle connections to be terminated. Let's send the keepalive message in order to prevent a client from closing
* Merge branch 'id-sync-sshd-sessions' into 'main'Patrick Bajao2022-05-111-0/+2
|\ | | | | | | | | Log the error that happens on sconn.Wait() See merge request gitlab-org/gitlab-shell!613
| * Log the error that happens on sconn.Wait()Igor Drozdov2022-05-061-0/+2
| | | | | | | | | | | | | | Warning level is used because a non-nil error is logged even for successful scenarios We plan to use it for debug reasons
* | Merge branch 'id-make-proxy-policy-configurable' into 'main'Stan Hu2022-05-103-15/+110
|\ \ | | | | | | | | | | | | Make PROXY policy configurable See merge request gitlab-org/gitlab-shell!619
| * | Make PROXY policy configurableIgor Drozdov2022-05-103-15/+110
| | | | | | | | | | | | | | | It would give us more flexibility when we decide to enable PROXY protocol
* | | Merge branch 'id-improve-errors-metrics' into 'main'Stan Hu2022-05-102-15/+14
|\ \ \ | |/ / |/| | | | | | | | Exclude authentication errors from error rate See merge request gitlab-org/gitlab-shell!611