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

client certificate validation #21221

Closed
wants to merge 1 commit into from
Closed

client certificate validation #21221

wants to merge 1 commit into from

Conversation

4xoc
Copy link

@4xoc 4xoc commented Sep 20, 2022

This PR implements client certificate validation for TLS based web server instances of Gitea. When CA_FILE is set in the server section, the contents of that file (one or more PEM encoded CA certs) is used to validate a client certificate sent by the user when establishing the TLS channel. The use of client certificate becomes mandatory once the setting is used for all requests going to the web server.

Existing configuration is not affected by this change. It's not expected this breaks anything for users not actively using this new feature.

No information of the client certificate is used for authentication or authorization within Gitea outside the TLS channel. Although it is possible to use certificate information to log in users automatically this is not implemented.

cmd/web_https.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 26, 2022
@4xoc
Copy link
Author

4xoc commented Nov 24, 2022

Hi @lunny, any chance this can be merged soonish?

@lunny lunny added the type/enhancement An improvement of existing functionality label Nov 25, 2022
@lunny
Copy link
Member

lunny commented Nov 25, 2022

Hi @lunny, any chance this can be merged soonish?

I think we need some tests.

@zeripath
Copy link
Contributor

I'm genuinely not sure of the use of this without adding in an authentication layer using the subject layer in the certificate.

Is that an intended follow-up to this PR?

@4xoc
Copy link
Author

4xoc commented Nov 27, 2022

No it is not. For my use-case the simple validation against a specific CA is enough. There's still the usual authentication happening just like now. The main benefit is that, with public reachable services that yet should be limited in access have a secure way of allowing access to such service. A possible attacker couldn't even abuse a security issue within Gitea because the tls connection isn't even established.

@denyskon
Copy link
Member

denyskon commented Aug 2, 2023

@4xoc Are you still interested in this PR? Could you add a test for it as requested previously?

@denyskon denyskon added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Aug 2, 2023
@4xoc
Copy link
Author

4xoc commented Aug 5, 2023

What would you like to see being tested here? Generally I'm not to sure what makes sense to really test here, other than maybe validating that tlsConfig actually contains some matching data and the config is parsed correctly. Everything else should already be in the tls and x509 packages.

@denyskon
Copy link
Member

@lunny Could you clarify what you'd like to see to be tested?

@lunny
Copy link
Member

lunny commented Aug 11, 2023

@lunny Could you clarify what you'd like to see to be tested?

Looks like it's not easy to have a test for the listening. Then maybe someone could have a manually test.

@denyskon denyskon mentioned this pull request Sep 22, 2023
@denyskon denyskon removed the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Oct 3, 2023
@denyskon denyskon added this to the 1.22.0 milestone Oct 3, 2023
@denyskon denyskon self-requested a review October 3, 2023 18:44
@denyskon
Copy link
Member

@4xoc Could you please resolve the conflicts? I'd then test the feature manually and probably approve the PR

@lafriks
Copy link
Member

lafriks commented Oct 18, 2023

Personally I don't see added value for this to be implemented in gitea directly if it does not add actual user authentication. This can easily be implemented already using pretty much any reverse proxy in front of gitea

@denyskon
Copy link
Member

I think it is okay to offer it directly, not everyone wants to use a reverse proxy. And after all this isn't a lot of code to be added.

@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 20, 2023
@github-actions github-actions bot added modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/docs labels Oct 20, 2023
@4xoc
Copy link
Author

4xoc commented Oct 20, 2023

@lafriks I get your point but the scope of doing user authentication is much larger than simply having the TLS engine take care of establishing the secure connection. Personally I don't have the need for authentication with certs thus this isn't part of the PR. I may look into this in the future or if there's genuine interest in that feature. Otherwise I'd not like to add code to authentication that is essentially not used by anyone and turns out to be a security risk in the future because nobody took care of it.

Copy link
Member

@denyskon denyskon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the feature manually and it works as expected

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 22, 2023
@denyskon denyskon requested a review from lunny October 22, 2023 12:52
@denyskon denyskon added type/feature Completely new functionality. Can only be merged if feature freeze is not active. and removed type/enhancement An improvement of existing functionality labels Oct 22, 2023
@4xoc
Copy link
Author

4xoc commented Nov 26, 2023

When can this finally be merged? The lack of progress is honestly quite annoying for a simple ans small PR like this. It's over a year now that this PR has been opened and every time I rebase it's just getting stale yet again. If something's missing or needs to be done please say so but the sheer lack of communication is unacceptable for such a small change.

@lafriks
Copy link
Member

lafriks commented Nov 27, 2023

@4xoc reverse proxy in front of gitea can also do client certificate authentication, so I see no added value for gitea if this does not result into actual user authentication.

Examples:
https://caddyserver.com/docs/json/apps/http/servers/tls_connection_policies/client_authentication/
http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_client_certificate
https://httpd.apache.org/docs/2.4/ssl/ssl_howto.html#allclients
etc

@wxiaoguang
Copy link
Contributor

I do not see enough benefit either by introducing this patch without a complete design.

For such spacial use case, reverse proxy could do well.

@wxiaoguang wxiaoguang removed this from the 1.22.0 milestone Nov 27, 2023
@wxiaoguang wxiaoguang added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Nov 27, 2023
@4xoc 4xoc closed this Nov 27, 2023
@Wizmaster
Copy link

Hello @4xoc
I'm a bit late in the discussion, I think your PR would be a useful addition in Gitea even without being able to properly authenticate the end users. It would allow Gitea to run behind a reverse-proxy and enable mTLS connection between the proxy and Gitea.
As far as I saw in Gitea documentation, it is currently not possible to do that. Your PR would enable that scenario. (and I would be happy it see it in Gitea then 😄)

@4xoc
Copy link
Author

4xoc commented Dec 18, 2023

Hey @Wizmaster, I'm sorry to say but you're probably too late for the party. I've lost any interest in this PR and will not pick it up anymore mainly because I don't see any chance this change getting through. I'm fully aware this sounds salty and arrogant, but I've got better things to do than chase a small PR for 1y+ to end up getting nowhere.

@Wizmaster
Copy link

No worries @4xoc! I quite understand.
If I find the time, I'll try to submit a new PR to add client cert support in Gitea.

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Feb 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/docs size/M Denotes a PR that changes 30-99 lines, ignoring generated files. topic/authentication type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants