-
Notifications
You must be signed in to change notification settings - Fork 44
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
Doesn't work with Drone 0.4 API #30
Comments
Yes, I just tested it too and the server crashes after some minutes. On the console I get this error:
|
Yup this was expected. Thanks for reporting. We're in the process of migrating to Drone v0.4 internally and will get this patched up once we have an instance to test against. I'm hoping it'll be ready to go within the next few weeks. |
Sounds good. It was more for in case anyone else came looking for answers. |
Any news? 😢 |
We're rolling out v4 internally right now. Once we've switched over completely (next week or two) updates to the wall are planned. |
FYI we're working on getting this rolled out this week. I'll be opening a PR on drone/drone soon. |
@scottferg while you are digging into the code ... there should be changes in place allowing cors (if not I can quickly adjust to enable). It would be awesome if we could make this client only (no backend) and store the url and token in local storage ... I would be happy to host the static site somewhere for people to use ... perhaps at wall.drone.io |
Great @scottferg ! In the meantime a collegue of mine ( @taueres ) forked this repo and made it work with some patches.. We will follow this closely ;) |
@bradrydzewski SGTM cc: @Tathanen since he's doing most of the legwork on this end |
👍 Yep, the new version is client-only, you'll just pass in the path to your API when you spin it up. |
Question for you tho @bradrydzewski about how the API authorization works. Right now I can get it to respond with JSON in the browser if I've already github-authenticated with drone proper, it registers a cookie on the domain ( |
Awesome!
You can append So the wall should be able to access the Drone API endpoints without being authenticated (via GitHub oauth) to Drone proper. |
Great! I was able to get the API responding successfully using that token via the Authorization header in postman, but I'm indeed getting CORS errors when trying it from the static app. So if you could get the |
yep, I think we were missing the CORS header on option requests. I just pushed the following change: a new Docker image for Drone should be available in ~5 minutes |
Okay we've got the new image installed, but now I'm gettin these in Firefox/Chrome:
I'm just using Angular's
Maybe you need to allow |
what if I remove that line all together? does cors require the |
or perhaps the accepted answer in this stackoverflow? http://stackoverflow.com/questions/13146892/cors-access-control-allow-headers-wildcard-being-ignored |
That stackoverflow answer may do it, as long as there aren't any headers you'd be afraid to allow. I... can't imagine there are any. |
for now I pushed harness/harness@398db0b which adds the recommended headers: accept, content-type, origin and authorization. If that doesn't work we can follow-up with a more comprehensive approach new image should be ready in ~5 min |
Great! I'm having trouble sending the Authorization header via the client for some reason (the problem there may be on my end), but I've got it working successfully if I send the token as part of the URL. |
@Tathanen no worries, the query parameter should work just fine as well. For reference you can see how it is done with the header in this node lib https://github.com/drone/drone-node/blob/master/lib/client.js#L20 |
Hey @bradrydzewski, I've got most things working now, but I'm caught up at the moment because the route I'm using ( Without it, I basically have to maintain a persistent recorded state of every build I've processed to avoid re-creating builds and PRs that have completed or closed, which is a lot of overhead. Do you suppose |
is it possible to use a combination of the |
@Tathanen @bradrydzewski This: https://github.com/taueres/drone-wall/blob/master/server/api.js#L11 is how I computed |
@taueres that's a pretty good idea actually, I think I'll start with that. @bradrydzewski I may tweak the methodology a bit knowing the exact mapping for each state that you've got there, between those two bits I may be able to get it working. I'll let you know! |
Alright it's lookin pretty good on my end, we're gonna trial it in-office for the week to make sure it's all workin the way it should, then I'll open a PR on this repo. |
Hey @bradrydzewski, I was afraid something like this might happen with how your new API is working, but after a while with the wall running, I'm getting a 400 response and this:
The wall tries to hit the API every 5 seconds to update the state of any running builds, pull in new ones, etc. Realistically it runs every 10 seconds because each call is taking around 6 seconds or so, and I wait for each request to complete before starting a new one. Not really sure what the workaround for this is, since my understanding is that you're hitting the GitHub API every time I hit the Drone API now. It'd need to cache all the repo info the first time and only respond with build data on subsequent requests, cutting out the need to hit GitHub as often. That sounds like a pretty fundamental change, though. I feel like some combination of websockets that report new builds with GitHub data, and updated builds with only build data, would be ideal. |
the repository list is cached, however, it looks like the |
Oh, lucky! 👍 |
Okay! Last issue here, @bradrydzewski. In many cases, we want the drone wall to not be publicly accessible. So I'm looking at my options for throwing a login gate on it, be it github oauth, google oauth, something like that. The problem is associating one of those options with the owner of the token that's driving the wall. The closest I can get is a github oauth that then uses the drone token to check the user info of the drone user, and compares the two usernames. But then only the user whose token was hard-coded into the wall can ever access it, which is quite inconvenient when a whole team wants to access it. The ideal scenario here would be if the drone wall could just read the drone @scottferg mentioned that wall.drone.io was potentially an option, and when hosting a local drone instance at something like drone.whatever.com, we'd also host the wall at something like wall.whatever.com. So the change on your end would be to make the We've done this before for other projects, sharing a cookie between subdomains to maintain a single user session, and it's been pretty effective. Thoughts? |
I think this approach is nice, but could be problematic. The wall may not be hostable on the same subdomain level; for example, I could host the wall locally, on a Intel NUC hooked to a TV, and have Drone\GitLab hosted somewhere else, or be public. Maybe it will be enough to provide also a fallback method, something very simple as a basic HTTP auth with fixed user\password, just to cover those "strange" setups.. |
Yeah, my thinking is that if the user-specific setup can't make the cookie sharing work, I'd still support the ability to just pass the token in during the build step. It wouldn't be secured then, but I imagine on local in-house setups, the login prompt isn't super necessary. It's just to protect the wall if it's hosted on a public domain. |
@Tathanen I was thinking that you would provide the token when you visit the site, and it would be stored in local storage in the browser. This is based on the assumption that the wall is hooked up to a TV which means you would only need to do this step once. |
@bradrydzewski That's definitely an option, but at least in my experience a lot of people in our office like to pull the wall up on their machines here and there to check on build statuses. I've actually got the wall working a bit more responsively this time around so you can see the build status portion nicely on a phone. Requiring a manual token entry for each of these cases feels like a bit much, being able to read it from an existing cookie streamlines the process considerably. |
@Tathanen we have an endpoint in drone that let's you swap a GitHub token for a drone token (see https://github.com/drone/drone/blob/master/controller/login.go#L118). What if you give the ability to paste your drone token, or login with GitHub? If you choose that latter, you can use the browser-based oauth2 flow to fetch the GitHub token, exchange for a Drone token, and then store that in localstorage as if the user had pasted it themselves. |
@bradrydzewski Aha! That's the kind of thing I'm lookin for. It's the solution I was trying to solve for initially, using the GitHub oauth, but I didn't know this endpoint existed. So it's a |
@Tathanen it is a POST to I'm not sure this approach would be any better, though. You would need to expose your github client id and secret in your client side javascript, which puts us back to square one. |
@bradrydzewski hm yeah, the client ID probably isn't a big deal but the secret, don't wanna put that in there. Kinda brings us back to the shared cookie as the cleanest solution. Do you have any concerns with that approach? |
the problem with the cookie is that the drone cookie expires, which means it will get logged out every 72 hours. This could be problematic for some teams that have the TVs + small computers wall mounted. |
Hm, yeah we'd need a token exchange route the wall could hit every day or so to get a fresh one. That said, I've been using my drone token for wall testing for weeks now without it expiring. Not sure what that's about. |
Oh wait, you said cookie not token. Duh. Would it be possible to create a second cookie for a defined "wall." subdomain when users authenticate that doesn't expire? |
... or couldn't I just read the cookie that first time, then store the value in localstorage? I don't need the cookie past that initial authorization really. |
@Tathanen this wouldn't work because we use CSRF tokens within drone when using cookie-based authentication. This will prevent something like the wall from attempting to create a token, as it would fail CSRF verification. |
Well the wall doesn't need to create a token, it would just use the token value in the cookie wholesale. If there's no token present in a |
sorry if I'm misunderstanding, but the token in would it be possible for the default wall configuration to prompt the user for the drone url and token, so that the wall can be client side only (no server-side requirements) with a fallback to read the |
Sorry, when you said the cookie expires I thought you were referring to the cookie lifespan itself, not the token inside. Could you describe your fallback scenario there a bit more? How is the wall accessing the |
@Tathanen yes, the cookie containers a JWT token that has an expiration date of 72 hours encoded into the token itself.
The wall is not going to have access to
Here are some options off the top of my head:
|
I'd reeeally like to keep this entirely client-side, which leaves us with the third option there. It's basically what I'm doing already, just without a dedicated user input for the fields. I think it's kind of a pain, but at least it's a one-time process. I'll still allow the token to just be built in from the start for usecases where it'll only be accessed via an internal address, and access-control isn't a concern. |
PR finally ready: #31 |
Resolved by #31 |
This no longer functions with the Drone 0.4 API.
The text was updated successfully, but these errors were encountered: