Skip to content
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

check access denied by Gandi #39

Closed
cyayon opened this issue Dec 24, 2023 · 2 comments
Closed

check access denied by Gandi #39

cyayon opened this issue Dec 24, 2023 · 2 comments
Assignees

Comments

@cyayon
Copy link

cyayon commented Dec 24, 2023

I purpose to check Gandi response access denied. In case on bad API key or token, Gandi answer with 403 json.

Without this modification, gad script will try to create a new record.

update() create()

            new_record_message=$(get_json_field "message" "$new_record_json")
            if echo "$new_record_json" | grep -iE ":403,|access was denied|httpforbidden" >/dev/null 2>&1 ; then
                printf "Sorry, access was denied by gandi.\\n"
                printf "new_record_json:\\n---\\n%s\\n---\\n\\n" "$new_record_json"
                exit 9
            fi

check()

            record_json=$(rest "GET" "domains/${domain}/records/${1}/${record_type}")
            if echo "$record_json" | grep -iE ":403,|access was denied|httpforbidden" >/dev/null 2>&1 ; then
                printf "Sorry, access was denied by gandi.\\n"
                printf "record_json:\\n---\\n%s\\n---\\n\\n" "$record_json"
                exit 9
            fi

thanks

@brianreumere
Copy link
Owner

I like this idea. I'll add some basic error checking to the rest() function that will check for an error code in the response.

@brianreumere
Copy link
Owner

I added checking for 403 and 401 errors in v2.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants