-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix authorization method #97
Closed
+1
−4
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are changing this you need to use
as the header name not basic i believe.
also this orb is used in production and works right now. interesting to see that you get not found 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the proposed method in documention here https://circleci.com/docs/api/v2/#operation/listWorkflowJobs
![Screenshot 2022-02-11 at 22 38 58](https://user-images.githubusercontent.com/1590371/153673946-f0f55593-5192-49ff-8ce1-7c04739bb73a.png)
I'll try again next week and let you know, could it be linked somehow to using a different version of pipelines?
I was using
version: 2.1
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah the circleci docs arent great at the auth part. this PR will break the orb :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry my message wasn't very clear, based on documentation there are three possible authentication methods:
api_key_header
usingCircle-Token
header keybasic_auth
using basic authentication (the one I implemented in this PR)api_key_query
usingcircle-token
key in query parameters (not in headers), which is the method your are currently using, and which will be deprecated at some pointI used
basic_auth
butapi_key_header
would work fine as well :)Note: before making this PR I launched a CircleCi build with SSH session to test it, and it works for me, so I don't think it would break the orb (or is there something I missed 🤔 ?):
![Screenshot 2022-02-12 at 22 59 16](https://user-images.githubusercontent.com/1590371/153729971-cb142566-d708-4424-9d82-232791d63b11.png)
For some reason, in my case the
![Screenshot 2022-02-12 at 22 58 43](https://user-images.githubusercontent.com/1590371/153730000-a29d6c79-7b9e-4a9e-bac3-8922fd1fb77f.png)
api_key_query
method doesn't work though.This error wasn't covered and resulted in a 22 error code:
![Screenshot 2022-02-12 at 22 56 15](https://user-images.githubusercontent.com/1590371/153730027-e8565c50-9c83-473d-8c9f-416d1a8e4030.png)
I investigated via SSH to understand where the issue came from, and to me it seems related to authentication method.
By the way, thanks a lot for making this orb, I don't understand how this feature isn't built-in in circleci, your orb is really appreciated :)
Cheers!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: I just noticed this issue #76 is related to a exit code 22 as well, it might be the same underlying issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, there might be another issue.
When running the current script in ssh mode, circleci api authentication fails, resulting in
job_status
andjob_number
variables having""
value.Which is equivalent to "the job we wait for doesn't exist", since we check
"$job_status" == ""
:This is an issue that will be solved by proper authentication, but I cannot reproduce the code 22 error though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I found the reason for the code 22 exit status:
https://curl.se/mail/archive-2003-03/0079.html
For some reason the
![Screenshot 2022-02-13 at 20 41 34](https://user-images.githubusercontent.com/1590371/153771862-34ca4cb3-44de-4b4d-b42b-2d7511f9923b.png)
-s
option incurl
command hid it, but it seems to be the culprit.Because circleci orbs run with
![Screenshot 2022-02-13 at 20 54 30](https://user-images.githubusercontent.com/1590371/153772332-644e3ed3-f32c-4ffe-b19e-cd2038897689.png)
#!/bin/bash -eo pipefail
, even if script ends with aexit 0
, the status will be the last failing.https://stackoverflow.com/questions/68465355/what-is-the-meaning-of-set-o-pipefail-in-bash-script
Now, I've no idea why it occurs on some configuration, but not on yours (could you check if authentication really works, or if the failing auth is just silently ignored, resulting in thinking the job we wait for doesn't exist?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so i double checked this. the PR in the current state will not work.
=>
Authorization
header does not work with circle token.=> to use the Circle token method you need to have header
Circle-Token
i.e.
does not work
works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any preference so let's go with the
Circle-Token
header 👍It's strange though, for me it works in both cases 🤷♂️
![Screenshot 2022-02-14 at 11 57 14](https://user-images.githubusercontent.com/1590371/153851341-d96a23bc-9a43-4c30-8cbe-8f89fe02f768.png)