Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
92f13eb8
Commit
92f13eb8
authored
Sep 10, 2021
by
Christophe B Billheimer
Browse files
get both the CSRF token and session ID cookies, as they are both needed for login now
parent
1312ef7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_1984hosting.sh
View file @
92f13eb8
...
...
@@ -135,7 +135,7 @@ dns_1984hosting_rm() {
_1984hosting_login
()
{
if
!
_check_credentials
;
then return
1
;
fi
if
_check_cookie
;
then
if
_check_cookie
s
;
then
_debug
"Already logged in"
return
0
fi
...
...
@@ -150,9 +150,12 @@ _1984hosting_login() {
_debug2 response
"
$response
"
if
_contains
"
$response
"
'"loggedin": true'
;
then
One984HOSTING_COOKIE
=
"
$(
grep
-io
'sessionid=[^;]*;'
"
$HTTP_HEADER
"
|
tr
-d
';'
)
"
export
One984HOSTING_COOKIE
_saveaccountconf_mutable One984HOSTING_COOKIE
"
$One984HOSTING_COOKIE
"
One984HOSTING_SESSIONID_COOKIE
=
"
$(
grep
-io
'sessionid=[^;]*;'
"
$HTTP_HEADER
"
|
tr
-d
';'
)
"
One984HOSTING_CSRFTOKEN_COOKIE
=
"
$(
grep
-io
'csrftoken=[^;]*;'
"
$HTTP_HEADER
"
|
tr
-d
';'
)
"
export
One984HOSTING_SESSIONID_COOKIE
export
One984HOSTING_CSRFTOKEN_COOKIE
_saveaccountconf_mutable One984HOSTING_SESSIONID_COOKIE
"
$One984HOSTING_SESSIONID_COOKIE
"
_saveaccountconf_mutable One984HOSTING_CSRFTOKEN_COOKIE
"
$One984HOSTING_CSRFTOKEN_COOKIE
"
return
0
fi
return
1
...
...
@@ -169,21 +172,24 @@ _check_credentials() {
return
0
}
_check_cookie
()
{
One984HOSTING_COOKIE
=
"
${
One984HOSTING_COOKIE
:-
$(
_readaccountconf_mutable One984HOSTING_COOKIE
)
}
"
if
[
-z
"
$One984HOSTING_COOKIE
"
]
;
then
_debug
"No cached cookie found"
_check_cookies
()
{
One984HOSTING_SESSIONID_COOKIE
=
"
${
One984HOSTING_SESSIONID_COOKIE
:-
$(
_readaccountconf_mutable One984HOSTING_SESSIONID_COOKIE
)
}
"
One984HOSTING_CSRFTOKEN_COOKIE
=
"
${
One984HOSTING_CSRFTOKEN_COOKIE
:-
$(
_readaccountconf_mutable One984HOSTING_CSRFTOKEN_COOKIE
)
}
"
if
[
-z
"
$One984HOSTING_SESSIONID_COOKIE
"
]
||
[
-z
"
$One984HOSTING_CSRFTOKEN_COOKIE
"
]
;
then
_debug
"No cached cookie(s) found"
return
1
fi
_authget
"https://management.1984hosting.com/accounts/loginstatus/"
if
_contains
"
$response
"
'"ok": true'
;
then
_debug
"Cached cookie still valid"
_debug
"Cached cookie
s
still valid"
return
0
fi
_debug
"Cached cookie no longer valid"
One984HOSTING_COOKIE
=
""
_saveaccountconf_mutable One984HOSTING_COOKIE
"
$One984HOSTING_COOKIE
"
_debug
"Cached cookies no longer valid"
One984HOSTING_SESSIONID_COOKIE
=
""
One984HOSTING_CSRFTOKEN_COOKIE
=
""
_saveaccountconf_mutable One984HOSTING_SESSIONID_COOKIE
"
$One984HOSTING_SESSIONID_COOKIE
"
_saveaccountconf_mutable One984HOSTING_CSRFTOKEN_COOKIE
"
$One984HOSTING_CSRFTOKEN_COOKIE
"
return
1
}
...
...
@@ -217,7 +223,8 @@ _get_root() {
# add extra headers to request
_authget
()
{
export
_H1
=
"Cookie:
$One984HOSTING_COOKIE
"
export
_H1
=
"Cookie:
$One984HOSTING_SESSIONID_COOKIE
"
export
_H2
=
"Cookie:
$One984HOSTING_CSRFTOKEN_COOKIE
"
_response
=
$(
_get
"
$1
"
| _normalizeJson
)
_debug2 _response
"
$_response
"
}
...
...
@@ -225,12 +232,14 @@ _authget() {
# truncate huge HTML response
# echo: Argument list too long
_htmlget
()
{
export
_H1
=
"Cookie:
$One984HOSTING_COOKIE
"
export
_H1
=
"Cookie:
$One984HOSTING_SESSIONID_COOKIE
"
export
_H2
=
"Cookie:
$One984HOSTING_CSRFTOKEN_COOKIE
"
_response
=
$(
_get
"
$1
"
|
grep
"
$2
"
| _head_n 1
)
}
# add extra headers to request
_authpost
()
{
export
_H1
=
"Cookie:
$One984HOSTING_COOKIE
"
export
_H1
=
"Cookie:
$One984HOSTING_SESSIONID_COOKIE
"
export
_H2
=
"Cookie:
$One984HOSTING_CSRFTOKEN_COOKIE
"
_response
=
$(
_post
"
$1
"
"
$2
"
)
}
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