-
Notifications
You must be signed in to change notification settings - Fork 31
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
[enhancement] Implement auth provider for GitHub #128
Comments
👍👍👍
Big 👍
I don't have a lot of thoughts here yet. However, i do think getting some kind of PoC working - perhaps a combination of a PR to actual code and an example in a (new) |
Today, I actually managed to bring up a PoC that uses properly configured kubernetes objects that acts as a single server! It was quite some trial-and-error, but it is done! The core part is an apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: giftless
labels:
app.kubernetes.io/name: giftless
app.kubernetes.io/instance: giftless
annotations:
# automatic TLS provisioning
#cert-manager.io/cluster-issuer: letsencrypt
# forwarding to github requires TLS (that means giftless uwsgi also needs to use TLS)
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
# arbitrarily higher limit than usual
nginx.ingress.kubernetes.io/proxy-body-size: 5g
# pretending the caller targets github.com
nginx.ingress.kubernetes.io/upstream-vhost: github.com
# needed for path matching and rewriting
nginx.ingress.kubernetes.io/use-regex: "true"
# strip the '.git/info/lfs' part from the default LFS URI to please giftless demands
nginx.ingress.kubernetes.io/rewrite-target: /$1$2
spec:
ingressClassName: nginx
#tls:
# - hosts:
# - "git.example.com"
# secretName: git.example.com-tls
rules:
- host: "git.example.com"
http:
paths:
# only this path routes to the giftless service
- path: /(.+)\.git/info/lfs(/.*|$)
pathType: ImplementationSpecific
backend:
service:
name: giftless
port:
number: 443
# anything else goes to an "externalName" service effectively routing to github.com
- path: /(.+|$)
pathType: ImplementationSpecific
backend:
service:
name: giftless-github-forward
port:
number: 443 The remaining cunning part is the apiVersion: v1
kind: Service
metadata:
name: giftless-github-forward
labels:
app.kubernetes.io/name: giftless
app.kubernetes.io/instance: giftless
spec:
type: ExternalName
externalName: github.com While this happened entirely outside of giftless, I definitely spotted a room for improvement 1️⃣, which is - making giftless handle the URI in the default git-lfs format I'm also glad that giftless is not sensitive to the This setup indeed works and I can confirm the commandline Once the token is saved in one's creds helper the user experience is so far completely transparent and no LFS config needs to be done. Even the
I noticed that giftless returned |
@vit-zikmund wow, great progress 👏👏
This is potentially something to change inside of Giftless if we can identify the relevant part. |
Oooh, that is elegant! |
Thanks! 😉 But I suppose that solution has a little trouble I found today. Quoting myself...
While using the One can set the All in all, the ingress/proxy routing needs better rules for |
OK, here's a second take with an Envoy proxy sidecar. The config is a little verbose, but it does exactly the same as the thing above, plus it's less of a routing spaghetti hell. It should also support the There's also no URI rewrite for giftless, as it's now supposed to support the native endpoints.
|
Just verified the envoy settings to work. All I had to change in my production setup were the port numbers. |
@vit-zikmund this is great 👏👏 Thank-you so much for sharing 🙏 |
Just played a bit with with the SSH possibilities, and got as far as calling github's ssh '--' '[email protected]' 'git-lfs-authenticate $ORG/$REPO.git download'
{
"href": "https://lfs.github.com/$ORG/$REPO",
"header": {
"Authorization": "RemoteAuth gitauth-v1-gsa0wDFqfuz8wDtKwSK08A0SG7AZY5Edc-hl3OWe0eDA5iSrDpLOZg6jXoKmbWVtYmVyuXVzZXI6NzU0NDM0NDg6dml0LXppa211bmSlcHJvdG-jc3No"
},
"expires_at": "2024-04-04T12:55:58Z",
"expires_in": 599 The returned Anyway, this means the way to verify the SSH login has proper permissions to a certain GitHub repo won't work. If only there would be a public endpoint to verify this token's permissions, or a way to get a real personal access token via SSH... alas, we're not in the '90s anymore 💾😄. Every other workaround I could think of eventually circles back to the personal access token, so closing this investigation as a dead end. |
Alright folks, it's about time for me to tie this up and move on:
|
The last pieces of the puzzle are merged to master. Here's the full feature with a ribbon on top. Thank you so much @athornton for your guidance and help, and, naturally, @rufuspollock & co. for their dedication to open source ❤️ Now don't be a stranger and carve us that new release, right? 😏 The plate Adam prepared is hardly getting any more silver. Thank you all once again! |
A pretty straightforward use case for
giftless
is to divert the LFS from a common github repo to one's own storage. But that storage suddenly needs to deal with authentication and authorization, most likely a bit more capable than the crude "Dummy authentication module" and a bit less demanding on one's infrastructure than the otherwise inspiring JWT module.A nice and readily deployable midpoint might be to tap the existing github access management and allow
giftless
access with the same creds normally used for github.One of the contemporary ways of logging into github is via HTTPS, where the same login creds (personal access token) can be also used to access the github REST/graphql API. It's then possible to verify if holder of such token is eligible to read/write to a particular repository. This information can be easily leveraged to provide/restrict access to the "same" path (org/repo) on the LFS storage.
This has been apparently already proved to work in a couple PoCs I know (#121 - accidental kickoff 😇, still too raw, lsst-sqre/giftless-github-proxy-auth - more mature, but abandoned).
There are yet unexplored limitations for using this with SSH, but testing out how github plays along with the
git-lfs-authenticate
protocol is surely worth a shot.I'd also like to explore/discuss some potential solutions for hiding the two different hostnames (
github.com
&your.private.giftless.com
) under one hood (hostname), so anygit
credential helper would offer the same creds one is already using for github for both thegit
andgit-lfs
operations. This should be possible thanks to the automatic LFS server discovery (which works pretty much by appending.git/info/lfs
to the usual git url). Such solution likely requires some kind of reverse proxy routing (thinking of an nginx/envoy/haproxy sidecar). One downside is that this will drag (otherwise readily available) files from github through the proxy (those transfers should be small, though). If this (the credentials sharing w/o a proxy) could be done with somegit
config, that might be better, but I don't know about any such thing.Otherwise one is likely supposed to override the LFS URL with
git config remote.origin.lfsurl https://your.private.giftless.com/org/repo
or such and provide the same HTTPS credentials twice.Maybe there are other options I missed? Thanks for your help!
Tasks
The text was updated successfully, but these errors were encountered: