์ด ๋ฌธ์์์๋ reCAPTCHA์ ํ๋ก๊ทธ๋๋งคํฑ ๋ฐฉ์์ผ๋ก ์ธ์ฆํ๋ ๋ฐฉ๋ฒ์ ์ค๋ช ํฉ๋๋ค. reCAPTCHA์ ์ธ์ฆํ๋ ๋ฐฉ๋ฒ์ API์ ์ก์ธ์คํ๋ ๋ฐ ์ฌ์ฉํ๋ ์ธํฐํ์ด์ค์ ์ฝ๋๊ฐ ์คํ๋๋ ํ๊ฒฝ์ ๋ฐ๋ผ ๋ค๋ฆ ๋๋ค.
Google Cloud ์ธ์ฆ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ธ์ฆ ๋ฉ์๋๋ฅผ ์ฐธ์กฐํ์ธ์.
API ์ก์ธ์ค
reCAPTCHA๋ ํ๋ก๊ทธ๋๋งคํฑ ์ก์ธ์ค๋ฅผ ์ง์ํฉ๋๋ค. ๋ค์ ๋ฐฉ๋ฒ์ผ๋ก API์ ์ก์ธ์คํ ์ ์์ต๋๋ค.
ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
reCAPTCHA ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ํ๋ก๊ทธ๋๋งคํฑ ๋ฐฉ์์ผ๋ก reCAPTCHA์ ์ธ์ฆํ ์ ์๋๋ก ๊ณ ๊ธ ์ธ์ด ์ง์์ ์ ๊ณตํฉ๋๋ค. Google Cloud API ํธ์ถ์ ์ธ์ฆํ๊ธฐ ์ํด ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ์ ํ๋ฆฌ์ผ์ด์ ๊ธฐ๋ณธ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด(ADC)๋ฅผ ์ง์ํฉ๋๋ค. ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ์ ์๋ ์์น ์งํฉ์์ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ฐพ๊ณ ์ด๋ฌํ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ฌ์ฉํด์ API์ ๋ํ ์์ฒญ์ ์ธ์ฆํฉ๋๋ค. ADC๋ฅผ ์ฌ์ฉํ๋ฉด ์ ํ๋ฆฌ์ผ์ด์ ์ฝ๋๋ฅผ ์์ ํ ํ์ ์์ด ๋ก์ปฌ ๊ฐ๋ฐ ๋๋ ํ๋ก๋์ ๊ณผ ๊ฐ์ ๋ค์ํ ํ๊ฒฝ์์ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ ๊ณตํ ์ ์์ต๋๋ค.
Google Cloud CLI
gcloud CLI๋ฅผ ์ฌ์ฉํ์ฌ reCAPTCHA์ ์ก์ธ์คํ ๋ gcloud CLI ๋ช ๋ น์ด์์ ์ฌ์ฉํ๋ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ์ฌ์ฉ์ ๊ณ์ ์ผ๋ก gcloud CLI์ ๋ก๊ทธ์ธํฉ๋๋ค.
์กฐ์ง์ ๋ณด์ ์ ์ฑ ์ผ๋ก ์ธํด ์ฌ์ฉ์ ๊ณ์ ์ ํ์ํ ๊ถํ์ด ์๋ ๊ฒฝ์ฐ ์๋น์ค ๊ณ์ ๊ฐ์ฅ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์์ธํ ๋ด์ฉ์ gcloud CLI ์ฌ์ฉ์ ์ํ ์ธ์ฆ์ ์ฐธ์กฐํ์ธ์. reCAPTCHA์ gcloud CLI๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ gcloud CLI ์ฐธ์กฐ ํ์ด์ง๋ฅผ ์ฐธ์กฐํ์ธ์.
REST
gcloud CLI ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ์ ํ๋ฆฌ์ผ์ด์ ๊ธฐ๋ณธ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ฌ์ฉํ์ฌ reCAPTCHA API์ ์ธ์ฆํ ์ ์์ต๋๋ค. REST ์์ฒญ ์ธ์ฆ์ ๋ํ ์์ธํ ๋ด์ฉ์ REST๋ฅผ ์ฌ์ฉํ์ฌ ์ธ์ฆ์ ์ฐธ์กฐํ์ธ์. ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด ์ ํ์ gcloud CLI ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด ๋ฐ ADC ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ฐธ์กฐํ์ธ์.
API ํค
API ํค๋ฅผ ์ฌ์ฉํ๋ฉด ํธ์ถ์ ID๋ฅผ ํ์ธํ์ง ์๊ณ ์ฒญ๊ตฌ ๋ฐ ํ ๋น๋ ๋ชฉ์ ์ผ๋ก ์ฌ์ฉ๋๋ API ํธ์ถ์ ํ๋ก์ ํธ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. API ํค๋ API ํค๋ฅผ ์ง์ํ๋ API ๋ฉ์๋์์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
reCAPTCHA๋ ๋ค์ API ๋ฉ์๋์ API ํค๋ฅผ ์ง์ํฉ๋๋ค.
projects.assessments.create
projects.assessments.annotate
ListRelatedAccountGroupMemberships
ListRelatedAccountGroups
SearchRelatedAccountGroupMemberships
ListFirewallPolicies
API ํค ์ฌ์ฉ์ ๋ํ ์ผ๋ฐ์ ์ธ ๋ด์ฉ์ API ํค๋ฅผ ์ฌ์ฉํ์ฌ ์ธ์ฆ์ ์ฐธ์กฐํ์ธ์.
reCAPTCHA ์ธ์ฆ ์ค์
์ธ์ฆ ์ค์ ๋ฐฉ๋ฒ์ ์ฝ๋๋ฅผ ์คํ ์ค์ธ ํ๊ฒฝ์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋๋ค.
์ธ์ฆ ์ค์ ์ ์ํ ๊ฐ์ฅ ์ผ๋ฐ์ ์ธ ์ต์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ์ธ์ฆ์ ๋ํ ์ถ๊ฐ ์ต์ ๋ฐ ์์ธํ ๋ด์ฉ์ ์ธ์ฆ ๋ฐฉ๋ฒ์ ์ฐธ์กฐํ์ธ์.
๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ์ฉ
๋ค์ ๋ฐฉ๋ฒ์ผ๋ก ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ์ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค.
- ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋๋ ์๋ ํํฐ ๋๊ตฌ์ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด
- ๋ช ๋ น์ค์ ํตํ REST ์์ฒญ์ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด
- ์๋น์ค ๊ณ์ ๊ฐ์ฅ
ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋๋ ์๋ ํํฐ ๋๊ตฌ
๋ก์ปฌ ํ๊ฒฝ์์ ์ ํ๋ฆฌ์ผ์ด์ ๊ธฐ๋ณธ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด(ADC)๋ฅผ ์ค์ ํฉ๋๋ค.
-
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
๋ก๊ทธ์ธ ํ๋ฉด์ด ํ์๋ฉ๋๋ค. ๋ก๊ทธ์ธํ๋ฉด ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ ADC์์ ์ฌ์ฉํ๋ ๋ก์ปฌ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด ํ์ผ์ ์ ์ฅ๋ฉ๋๋ค.
๋ก์ปฌ ํ๊ฒฝ์์ ADC ์ฌ์ฉ์ ๋ํ ์์ธํ ๋ด์ฉ์ ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ์ฉ ADC ์ค์ ์ ์ฐธ์กฐํ์ธ์.
๋ช ๋ น์ค์ REST ์์ฒญ
๋ช
๋ น์ค์์ REST ์์ฒญ์ ์ํํ ๋๋ ์์ฒญ์ ์ ์กํ๋ ๋ช
๋ น์ด์ ์ผ๋ถ๋ก gcloud auth print-access-token
์ ํฌํจํ์ฌ gcloud CLI ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๋ค์ ์์์์๋ ์ง์ ๋ ํ๋ก์ ํธ์ ๋ํ ์๋น์ค ๊ณ์ ์ ๋์ดํฉ๋๋ค. REST ์์ฒญ์๋ ๋์ผํ ํจํด์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์์ฒญ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ๋ค์์ ๋ฐ๊ฟ๋๋ค.
- PROJECT_ID: Google Cloud ํ๋ก์ ํธ ID์ ๋๋ค.
์์ฒญ์ ๋ณด๋ด๋ ค๋ฉด ๋ค์ ์ต์ ์ค ํ๋๋ฅผ ํผ์นฉ๋๋ค.
REST ๋ฐ gRPC๋ฅผ ์ฌ์ฉํ์ฌ ์ธ์ฆํ๋ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ REST ์ฌ์ฉ์ ์ํ ์ธ์ฆ์ ์ฐธ์กฐํ์ธ์. ๋ก์ปฌ ADC ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด์ gcloud CLI ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด์ ์ฐจ์ด์ ์ ๋ํ ์์ธํ ๋ด์ฉ์ gcloud CLI ์ธ์ฆ ๊ตฌ์ฑ ๋ฐ ADC ๊ตฌ์ฑ์ ์ฐธ์กฐํ์ธ์.
์๋น์ค ๊ณ์ ๊ฐ์ฅ
๋๋ถ๋ถ์ ๊ฒฝ์ฐ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ฌ์ฉํ์ฌ ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ์์ ์ธ์ฆํ ์ ์์ต๋๋ค. ์ด๋ ๊ฒ ํ ์ ์๊ฑฐ๋ ์๋น์ค ๊ณ์ ์ ํ ๋น๋ ๊ถํ์ ํ
์คํธํด์ผ ํ๋ ๊ฒฝ์ฐ์๋ ์๋น์ค ๊ณ์ ๊ฐ์ฅ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์๋น์ค ๊ณ์ ํ ํฐ ์์ฑ์(roles/iam.serviceAccountTokenCreator
) IAM ์ญํ ์ ํฌํจ๋ iam.serviceAccounts.getAccessToken
๊ถํ์ด ์์ด์ผ ํฉ๋๋ค.
gcloud config set
๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ์๋น์ค ๊ณ์ ๊ฐ์ฅ์ ์ฌ์ฉํ๋๋ก gcloud CLI๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค.
gcloud config set auth/impersonate_service_account SERVICE_ACCT_EMAIL
์ผ๋ถ ์ธ์ด์ ๊ฒฝ์ฐ ์๋น์ค ๊ณ์ ๊ฐ์ฅ์ ์ฌ์ฉํ์ฌ ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ฌ์ฉํ ๋ก์ปฌ ADC ํ์ผ์ ๋ง๋ค ์ ์์ต๋๋ค. ์ด ๋ฐฉ๋ฒ์ Go, Java, Node.js, Python ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์๋ง ์ง์๋๋ฉฐ ๋ค๋ฅธ ์ธ์ด์์๋ ์ง์๋์ง ์์ต๋๋ค.
์๋น์ค ๊ณ์ ๊ฐ์ฅ์ผ๋ก ๋ก์ปฌ ADC ํ์ผ์ ์ค์ ํ๋ ค๋ฉด gcloud auth application-default login
๋ช
๋ น์ด์ ํจ๊ป --impersonate-service-account
ํ๋๊ทธ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
gcloud auth application-default login --impersonate-service-account=SERVICE_ACCT_EMAIL
์๋น์ค ๊ณ์ ๊ฐ์ฅ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์๋น์ค ๊ณ์ ๊ฐ์ฅ ์ฌ์ฉ์ ์ฐธ์กฐํ์ธ์.
Google Cloud
Google Cloud์์ ์คํ๋๋ ์ํฌ๋ก๋๋ฅผ ์ธ์ฆํ๋ ค๋ฉด ์ฝ๋๊ฐ ์คํ ์ค์ธ ์ปดํจํ ๋ฆฌ์์ค(์: Compute Engine ๊ฐ์ ๋จธ์ (VM) ์ธ์คํด์ค)์ ์ฐ๊ฒฐ๋ ์๋น์ค ๊ณ์ ์ ์ฌ์ฉ์ ์ธ์ฆ ์ ๋ณด๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ด ๋ฐฉ์์ Google Cloud ์ปดํจํ ๋ฆฌ์์ค์์ ์คํ๋๋ ์ฝ๋์ ์ ํธ๋๋ ์ธ์ฆ ๋ฐฉ๋ฒ์ ๋๋ค.
๋๋ถ๋ถ์ ์๋น์ค์ ๊ฒฝ์ฐ ์ฝ๋๋ฅผ ์คํํ ๋ฆฌ์์ค๋ฅผ ๋ง๋ค ๋ ์๋น์ค ๊ณ์ ์ ์ฐ๊ฒฐํด์ผ ํฉ๋๋ค. ์ดํ์๋ ์๋น์ค ๊ณ์ ์ ์ถ๊ฐํ๊ฑฐ๋ ๊ต์ฒดํ ์ ์์ต๋๋ค. ์ธ์ ๋ ์ง VM ์ธ์คํด์ค์ ์๋น์ค ๊ณ์ ์ ์ฐ๊ฒฐํ ์ ์๊ฒ ํด์ฃผ๋ Compute Engine์ ์์ธ์ ๋๋ค.
gcloud CLI๋ฅผ ์ฌ์ฉํ์ฌ ์๋น์ค ๊ณ์ ์ ๋ง๋ค๊ณ ๋ฆฌ์์ค์ ์ฐ๊ฒฐํฉ๋๋ค.
-
Google Cloud CLI๋ฅผ ์ค์นํฉ๋๋ค. ์ค์น ํ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํ์ฌ Google Cloud CLI๋ฅผ ์ด๊ธฐํํฉ๋๋ค.
gcloud init
์ธ๋ถ ID ๊ณต๊ธ์ ์ฒด (IdP)๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ๋จผ์ ์ ํด ID๋ก gcloud CLI์ ๋ก๊ทธ์ธํด์ผ ํฉ๋๋ค.
-
Set up authentication:
-
Create the service account:
gcloud iam service-accounts create SERVICE_ACCOUNT_NAME
Replace
SERVICE_ACCOUNT_NAME
with a name for the service account. -
To provide access to your project and your resources, grant a role to the service account:
gcloud projects add-iam-policy-binding PROJECT_ID --member="serviceAccount:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com" --role=ROLE
Replace the following:
SERVICE_ACCOUNT_NAME
: the name of the service accountPROJECT_ID
: the project ID where you created the service accountROLE
: the role to grant
- To grant another role to the service account, run the command as you did in the previous step.
-
Grant the required role to the principal that will attach the service account to other resources.
gcloud iam service-accounts add-iam-policy-binding SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com --member="user:USER_EMAIL" --role=roles/iam.serviceAccountUser
Replace the following:
SERVICE_ACCOUNT_NAME
: the name of the service accountPROJECT_ID
: the project ID where you created the service accountUSER_EMAIL
: the email address for a Google Account
-
-
์ฝ๋๋ฅผ ์คํํ ๋ฆฌ์์ค๋ฅผ ๋ง๋ค๊ณ ์ด ๋ฆฌ์์ค์ ์๋น์ค ๊ณ์ ์ ์ฐ๊ฒฐํฉ๋๋ค. ์๋ฅผ ๋ค์ด Compute Engine์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ๋ค์ ์๋ด๋ฅผ ๋ฐ๋ฅด์ธ์.
Create a Compute Engine instance. Configure the instance as follows:INSTANCE_NAME
์ ์ํ๋ ์ธ์คํด์ค ์ด๋ฆ์ผ๋ก ๋ฐ๊ฟ๋๋ค.-
--zone
ํ๋๊ทธ๋ฅผ ์ธ์คํด์ค๋ฅผ ๋ง๋ค ์์ญ์ผ๋ก ์ค์ ํฉ๋๋ค. -
--service-account
ํ๋๊ทธ๋ฅผ ๋ง๋ ์๋น์ค ๊ณ์ ์ ์ด๋ฉ์ผ ์ฃผ์๋ก ์ค์ ํฉ๋๋ค.
gcloud compute instances create INSTANCE_NAME --zone=ZONE --service-account=SERVICE_ACCOUNT_EMAIL
Google API ์ธ์ฆ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ธ์ฆ ๋ฐฉ๋ฒ์ ์ฐธ์กฐํ์ธ์.
์จํ๋ ๋ฏธ์ค ๋๋ ๋ค๋ฅธ ํด๋ผ์ฐ๋ ์ ๊ณต์ ์ฒด
Google Cloud ์ธ๋ถ์์ ์ธ์ฆ์ ์ค์ ํ๋ ๋ฐ ์ ํธ๋๋ ๋ฐฉ๋ฒ์ ์ํฌ๋ก๋ ์์ด๋ดํฐํฐ ์ ํด๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค. ์์ธํ ๋ด์ฉ์ ์ธ์ฆ ๋ฌธ์์์ ์จํ๋ ๋ฏธ์ค ๋๋ ๋ค๋ฅธ ํด๋ผ์ฐ๋ ์ ๊ณต์ ์ฒด์ ADC ์ค์ ์ ์ฐธ์กฐํ์ธ์.
reCAPTCHA ์ก์ธ์ค ์ ์ด
reCAPTCHA์ ์ธ์ฆํ ํ์๋ Google Cloud ๋ฆฌ์์ค์ ์ก์ธ์คํ ์ ์๋ ๊ถํ์ด ์์ด์ผ ํฉ๋๋ค. reCAPTCHA๋ Identity and Access Management (IAM)๋ฅผ ์ฌ์ฉํ์ฌ ์น์ธ์ ๋ฐ์ต๋๋ค.
reCAPTCHA์ ์ญํ ์ ๋ํ ์์ธํ ๋ด์ฉ์ IAM์ผ๋ก ์ก์ธ์ค ์ ์ด๋ฅผ ์ฐธ์กฐํ์ธ์. IAM ๋ฐ ์น์ธ์ ๋ํ ์์ธํ ๋ด์ฉ์ IAM ๊ฐ์๋ฅผ ์ฐธ์กฐํ์ธ์.
๋ค์ ๋จ๊ณ
- Google Cloud ์ธ์ฆ ๋ฐฉ๋ฒ ์์๋ณด๊ธฐ
- ์ธ์ฆ ์ฌ์ฉ ์ฌ๋ก ๋ชฉ๋ก ์ดํด๋ณด๊ธฐ