re-apply fixing jwt-curl by introducing client-id and -secret (was included in the reversal) (#201)
Co-authored-by: Michael Hoennig <michael@hoennig.de> Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/201
This commit is contained in:
@@ -5,5 +5,9 @@ export HSADMINNG_POSTGRES_ADMIN_USERNAME=admin
|
|||||||
export HSADMINNG_SUPERUSER=import-superuser@hostsharing.net
|
export HSADMINNG_SUPERUSER=import-superuser@hostsharing.net
|
||||||
export HSADMINNG_OFFICE_DATA_SQL_FILE
|
export HSADMINNG_OFFICE_DATA_SQL_FILE
|
||||||
export HSADMINNG_JWT_TOKEN_URL=http://localhost:8080/fake-jwt/token
|
export HSADMINNG_JWT_TOKEN_URL=http://localhost:8080/fake-jwt/token
|
||||||
|
export HSADMINNG_JWT_CLIENT_ID=hsscript.ng
|
||||||
|
export HSADMINNG_JWT_CLIENT_SECRET=
|
||||||
|
export HSADMINNG_JWT_USERNAME=superuser-alex@hostsharing.net
|
||||||
|
export HSADMINNG_JWT_PASSWORD=password
|
||||||
|
|
||||||
export LANG=en_US.UTF-8
|
export LANG=en_US.UTF-8
|
||||||
|
|||||||
+3
-2
@@ -8,7 +8,8 @@ unset HSADMINNG_OFFICE_DATA_SQL_FILE
|
|||||||
|
|
||||||
unset HSADMINNG_JWT_ISSUER
|
unset HSADMINNG_JWT_ISSUER
|
||||||
unset HSADMINNG_JWT_JWKS_URL
|
unset HSADMINNG_JWT_JWKS_URL
|
||||||
|
unset HSADMINNG_JWT_TOKEN_URL
|
||||||
|
unset HSADMINNG_JWT_CLIENT_ID
|
||||||
|
unset HSADMINNG_JWT_CLIENT_SECRET
|
||||||
unset HSADMINNG_JWT_USERNAME
|
unset HSADMINNG_JWT_USERNAME
|
||||||
unset HSADMINNG_JWT_PASSWORD
|
unset HSADMINNG_JWT_PASSWORD
|
||||||
unset HSADMINNG_JWT_TOKEN_URL
|
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -102,12 +102,12 @@ function jwtLogin() {
|
|||||||
# OAuth2 Resource Owner Password Credentials Grant (public client)
|
# OAuth2 Resource Owner Password Credentials Grant (public client)
|
||||||
trace "+ curl --fail-with-body --show-error -X POST \
|
trace "+ curl --fail-with-body --show-error -X POST \
|
||||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
-d \"grant_type=password&username=$HSADMINNG_JWT_USERNAME&password=$HSADMINNG_JWT_PASSWORD_DISPLAY\" \
|
-d \"grant_type=password&client_id=$HSADMINNG_JWT_CLIENT_ID&client_secret=$HSADMINNG_JWT_CLIENT_SECRET&username=$HSADMINNG_JWT_USERNAME&password=$HSADMINNG_JWT_PASSWORD_DISPLAY\" \
|
||||||
$HSADMINNG_JWT_TOKEN_URL -o ~/.jwt-token.response"
|
$HSADMINNG_JWT_TOKEN_URL -o ~/.jwt-token.response"
|
||||||
|
|
||||||
JWT_RESPONSE=$(curl --fail-with-body --show-error -X POST \
|
JWT_RESPONSE=$(curl --fail-with-body --show-error -X POST \
|
||||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||||
-d "grant_type=password&username=$HSADMINNG_JWT_USERNAME&password=$HSADMINNG_JWT_PASSWORD" \
|
-d "grant_type=password&client_id=$HSADMINNG_JWT_CLIENT_ID&client_secret=$HSADMINNG_JWT_CLIENT_SECRET&username=$HSADMINNG_JWT_USERNAME&password=$HSADMINNG_JWT_PASSWORD_DISPLAY" \
|
||||||
$HSADMINNG_JWT_TOKEN_URL 2>&1 | tee ~/.jwt-token.response)
|
$HSADMINNG_JWT_TOKEN_URL 2>&1 | tee ~/.jwt-token.response)
|
||||||
|
|
||||||
# Extract access token from JSON response
|
# Extract access token from JSON response
|
||||||
@@ -198,6 +198,8 @@ case "${1,,}" in
|
|||||||
"env") ## prints all related HSADMINNG_JWT_... environment variables; use '--show-password' to show the password as well
|
"env") ## prints all related HSADMINNG_JWT_... environment variables; use '--show-password' to show the password as well
|
||||||
# example: jwt-curl -show-password env
|
# example: jwt-curl -show-password env
|
||||||
echo "export HSADMINNG_JWT_TOKEN_URL=$HSADMINNG_JWT_TOKEN_URL"
|
echo "export HSADMINNG_JWT_TOKEN_URL=$HSADMINNG_JWT_TOKEN_URL"
|
||||||
|
echo "export HSADMINNG_JWT_CLIENT_ID=$HSADMINNG_JWT_CLIENT_ID"
|
||||||
|
echo "export HSADMINNG_JWT_CLIENT_SECRET=$HSADMINNG_JWT_CLIENT_SECRET"
|
||||||
echo "export HSADMINNG_JWT_USERNAME=$HSADMINNG_JWT_USERNAME"
|
echo "export HSADMINNG_JWT_USERNAME=$HSADMINNG_JWT_USERNAME"
|
||||||
if [ "$HSADMINNG_JWT_SHOW_PASSWORD" == "yes" ]; then
|
if [ "$HSADMINNG_JWT_SHOW_PASSWORD" == "yes" ]; then
|
||||||
echo "export HSADMINNG_JWT_PASSWORD=$HSADMINNG_JWT_PASSWORD"
|
echo "export HSADMINNG_JWT_PASSWORD=$HSADMINNG_JWT_PASSWORD"
|
||||||
|
|||||||
Reference in New Issue
Block a user