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

CGIT Improvements #155

Merged
merged 6 commits into from
Sep 5, 2024
Merged

CGIT Improvements #155

merged 6 commits into from
Sep 5, 2024

Conversation

charliemirabile
Copy link
Contributor

A more correct implementation of the CGI protocol when communicating with cgit allows us to produce more well formed html output, re-enable the plain view button, and allow clone over http.

401 should be used to request the client to authenitcate (e.g. using
http basic auth) and not just to indicate that they are not allowed
access to a resource. The HTTP 403 Forbidden status code is better.
Without the embedded option in the cgitrc cgit generates a full html page
with its own html and body tags that we were embedding within our existing
body creating ill-formed html documents.

We can also use noheader to suppress the header bar and avoid the need to
hide the logo with custom css rules.

By parsing the http headers returned from cgit we can also surface
information like content type to the client and suppress wrapping the
output in our html if it is supposed to be binary data which allows us to
bring back the plain view button.
We can wire up cgit to request credentials from a git client during a
clone operation via the basic authentication scheme that is part of HTTP
and verify them so that course materials can be hosted entirely in cgit.
no functional change, just moving the current one command used to start
orbit from being inline within a `CMD` instruction to a separate .sh
script to make way for adding more commands.
While the clone functionality works it bottlenecked by the speed of the
secure cryptographic hash needed to verify passwords. By caching recent
successful authentication attempts we can skip hashing the password
repeatedly.

Memcached is a simple and robust program that implements a memory only
cache that can be queried and updated using a text or binary protocol
over tcp, udp, or a unix domain socket. While there are python libraries
that can act as a client for a memcached daemon, all the libraries I
evaluated were unnesecarily bloated and complex as compared to just
calling the C library with our own bindings for the three functions
we need using the builtin python C foreign function interface module.
In order to minimize the security impact, the cache entries are set to
expire after only 2 seconds and are only stored in ram because of how
memcached works. Credentials are hashed before being stored and the
current timestamp is included in order to prevent the same credentials
from always having the same cache entry.
@theyoyojo theyoyojo merged commit 50d3ca1 into master Sep 5, 2024
@theyoyojo theyoyojo deleted the cgit_auth branch September 5, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants