Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
6a2c9a0d
Commit
6a2c9a0d
authored
Dec 20, 2021
by
racitup
Committed by
neil
Jan 06, 2022
Browse files
fix: floating token for github
parent
4dd709b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_mythic_beasts.sh
View file @
6a2c9a0d
...
@@ -161,7 +161,20 @@ _initAuth() {
...
@@ -161,7 +161,20 @@ _initAuth() {
return
0
return
0
}
}
# Github appears to use an outbound proxy for requests which means subsequent requests may not have the same
# source IP. The standard Mythic Beasts OAuth2 tokens are tied to an IP, meaning github test requests fail
# authentication. This works arounds this by using an undocumented MB API to obtain a token not tied to an
# IP just for the github tests.
_oauth2
()
{
_oauth2
()
{
printenv
if
[
-z
"
$TEST_DNS_SLEEP
"
]
;
then
return
_oauth2_std
else
return
_oauth2_github
fi
}
_oauth2_std
()
{
# HTTP Basic Authentication
# HTTP Basic Authentication
_H1
=
"Authorization: Basic
$(
echo
"
$MB_AK
:
$MB_AS
"
| _base64
)
"
_H1
=
"Authorization: Basic
$(
echo
"
$MB_AK
:
$MB_AS
"
| _base64
)
"
_H2
=
"Accepts: application/json"
_H2
=
"Accepts: application/json"
...
@@ -187,6 +200,24 @@ _oauth2() {
...
@@ -187,6 +200,24 @@ _oauth2() {
return
0
return
0
}
}
_oauth2_github
()
{
_H1
=
"Accepts: application/json"
export
_H1
body
=
"{
\"
login
\"
:{
\"
handle
\"
:
$MB_AK
,
\"
pass
\"
:
$MB_AS
,
\"
floating
\"
:1}}"
_info
"Getting Floating token..."
# body url [needbase64] [POST|PUT|DELETE] [ContentType]
response
=
"
$(
_post
"
$body
"
"
$MB_AUTH
"
""
"POST"
"application/json"
)
"
MB_TK
=
"
$(
echo
"
$response
"
| _egrep_o
"
\"
token
\"
:
\"
[^
\"
]*
\"
"
|
cut
-d
:
-f
2 |
tr
-d
'"'
)
"
if
[
-z
"
$MB_TK
"
]
;
then
_err
"Unable to get access_token"
_err
"
\n
$response
"
return
1
fi
_debug2 response
"
$response
"
return
0
}
# method path body_data
# method path body_data
_mb_rest
()
{
_mb_rest
()
{
# URL encoded body for single API operations
# URL encoded body for single API operations
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment