From eecf9633ff7279f54c8ef718a079d115401ee974 Mon Sep 17 00:00:00 2001 From: kimkiyong Date: Tue, 2 Jan 2024 21:06:34 +0900 Subject: [PATCH] fix: use channel access token --- .clouddeploy/run-prod.yaml | 6 ++++-- .env.sample | 3 ++- .github/workflows/deploy.yml | 3 ++- Makefile | 2 +- infra/config/env.go | 7 ++++--- infra/line/clinet.go | 2 +- infra/line/parser.go | 2 +- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.clouddeploy/run-prod.yaml b/.clouddeploy/run-prod.yaml index ffd2cf26..069d8dee 100644 --- a/.clouddeploy/run-prod.yaml +++ b/.clouddeploy/run-prod.yaml @@ -14,5 +14,7 @@ spec: env: - name: ENV value: production - - name: LINE_CHANNEL_TOKEN - value: dummy # from-param: ${line_token} + - name: LINE_CHANNEL_SECRET + value: dummy # from-param: ${line_secret_token} + - name: LINE_CHANNEL_ACCESS_TOKEN + value: dummy # from-param: ${line_access_token} diff --git a/.env.sample b/.env.sample index 59445037..775ea669 100644 --- a/.env.sample +++ b/.env.sample @@ -1 +1,2 @@ -LINE_CHANNEL_TOKEN=YOUR_CHANNEL_TOKEN +LINE_CHANNEL_SECRET=YOUR_CHANNEL_SECRET +LINE_CHANNEL_ACCESS_TOKEN=YOUR_CHANNEL_ACCESS_TOKEN diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 39e6ad29..d594838b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -57,7 +57,8 @@ jobs: region: "${{ env.REGION }}" skaffold_file: ".clouddeploy/skaffold.yaml" deploy_parameters: |- - line_token=${{ secrets.LINE_TOKEN }} + line_secret_token=${{ secrets.LINE_CHANNEL_SECRET }} + line_access_token=${{ secrets.LINE_CHANNEL_ACCESS_TOKEN }} - name: "Report Cloud Deploy release" run: |- diff --git a/Makefile b/Makefile index 2c6d5dba..a4d31294 100644 --- a/Makefile +++ b/Makefile @@ -51,4 +51,4 @@ deploy.release: --project=kyong0612-lab \ --region=asia-northeast1 \ --delivery-pipeline=fitness-support \ - --deploy-parameters="line_token=$(LINE_CHANNEL_TOKEN)" + --deploy-parameters="line_secret_token=$(LINE_CHANNEL_SECRET),line_access_token=$(LINE_CHANNEL_ACCESS_TOKEN)" diff --git a/infra/config/env.go b/infra/config/env.go index e7945a05..642637c0 100644 --- a/infra/config/env.go +++ b/infra/config/env.go @@ -6,9 +6,10 @@ import ( ) type config struct { - ENV string `env:"ENV" envDefault:"local"` - Port int `env:"PORT" envDefault:"8080"` - LINEChannelToken string `env:"LINE_CHANNEL_TOKEN,required"` + ENV string `env:"ENV" envDefault:"local"` + Port int `env:"PORT" envDefault:"8080"` + LINEChannelSecret string `env:"LINE_CHANNEL_SECRET,required"` + LINEChannelAccessToken string `env:"LINE_CHANNEL_ACCESS_TOKEN,required"` } var cfg config diff --git a/infra/line/clinet.go b/infra/line/clinet.go index 512e8a15..33d48bee 100644 --- a/infra/line/clinet.go +++ b/infra/line/clinet.go @@ -23,7 +23,7 @@ type client struct { func NewClient() (Client, error) { bot, err := messaging_api.NewMessagingApiAPI( - config.Get().LINEChannelToken, + config.Get().LINEChannelAccessToken, ) if err != nil { return nil, errors.Wrap(err, "failed to create line client") diff --git a/infra/line/parser.go b/infra/line/parser.go index f3bd6d10..6a3dfbaf 100644 --- a/infra/line/parser.go +++ b/infra/line/parser.go @@ -37,7 +37,7 @@ func ParseWebhookRequest(ctx context.Context, req *http.Request) ([]MessageEvent ) cb, err := webhook.ParseRequest( - config.Get().LINEChannelToken, + config.Get().LINEChannelSecret, req, ) if err != nil {