From 97149bc8d55ce29d95866a2fcc745a8a81e53846 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 3 Sep 2024 22:43:12 +0900 Subject: [PATCH 1/3] Add mew-oauth2 --- .emacs.d/.mew.d/oauth2/main.tf | 2 +- .terraformignore | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .terraformignore diff --git a/.emacs.d/.mew.d/oauth2/main.tf b/.emacs.d/.mew.d/oauth2/main.tf index e47c207..9686ce1 100644 --- a/.emacs.d/.mew.d/oauth2/main.tf +++ b/.emacs.d/.mew.d/oauth2/main.tf @@ -10,7 +10,7 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = "~> 3.0.0" + version = "~> 4.0.1" } } required_version = ">= 0.14.9" diff --git a/.terraformignore b/.terraformignore new file mode 100644 index 0000000..683293e --- /dev/null +++ b/.terraformignore @@ -0,0 +1,4 @@ +** + +!.emacs.d/.mew.d/oauth2/ +.emacs.d/.mew.d/oauth2/**/.terraform/ \ No newline at end of file From d103680f23e0bcaddbb12400d37331c993ce3ba9 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 3 Sep 2024 23:26:22 +0900 Subject: [PATCH 2/3] Fix directory --- .terraformignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.terraformignore b/.terraformignore index 683293e..5098ad4 100644 --- a/.terraformignore +++ b/.terraformignore @@ -1,4 +1,4 @@ ** -!.emacs.d/.mew.d/oauth2/ -.emacs.d/.mew.d/oauth2/**/.terraform/ \ No newline at end of file +!/.emacs.d/.mew.d/oauth2/ +/.emacs.d/.mew.d/oauth2/.terraform/ \ No newline at end of file From 715f2b8400fddf6a78d4aba9869bfec1f610071e Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Thu, 5 Sep 2024 01:08:19 +0900 Subject: [PATCH 3/3] Support OAuth2 to Mew --- .emacs.d/.mew.d/.mew.el | 2 +- .emacs.d/.mew.d/mew-config.el.dist | 23 ++++++++- .emacs.d/.mew.d/oauth2/README.md | 3 -- .emacs.d/.mew.d/oauth2/delegate-auth.php | 26 ---------- .emacs.d/.mew.d/oauth2/get-auth.php | 33 ------------- .emacs.d/.mew.d/oauth2/main.tf | 62 ------------------------ .emacs.d/.mew.d/oauth2/request_auth.php | 22 --------- .emacs.d/el-get.lock | 2 +- .emacs.d/init.el | 5 +- 9 files changed, 26 insertions(+), 152 deletions(-) delete mode 100644 .emacs.d/.mew.d/oauth2/README.md delete mode 100644 .emacs.d/.mew.d/oauth2/delegate-auth.php delete mode 100644 .emacs.d/.mew.d/oauth2/get-auth.php delete mode 100644 .emacs.d/.mew.d/oauth2/main.tf delete mode 100644 .emacs.d/.mew.d/oauth2/request_auth.php diff --git a/.emacs.d/.mew.d/.mew.el b/.emacs.d/.mew.d/.mew.el index d1f9673..8c13c45 100644 --- a/.emacs.d/.mew.d/.mew.el +++ b/.emacs.d/.mew.d/.mew.el @@ -12,7 +12,7 @@ (setq mew-addrbook-for-summary 'name) ;; マスターパスワード - (setq mew-use-master-passwd t) + (setq mew-use-master-passwd nil) ;; draft mode は auto-save しない (setq mew-draft-mode-auto-save -1) diff --git a/.emacs.d/.mew.d/mew-config.el.dist b/.emacs.d/.mew.d/mew-config.el.dist index dcf5c9e..9e9702c 100644 --- a/.emacs.d/.mew.d/mew-config.el.dist +++ b/.emacs.d/.mew.d/mew-config.el.dist @@ -2,7 +2,17 @@ '("User " "User " "User ")) - +(setopt mew-oauth2-client-id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com") +(setopt mew-oauth2-client-secret "xxxxxxxxxxxxxxxxxxxxxxxx") +(setopt mew-oauth2-redirect-url "http://localhost:8080") +(setopt mew-oauth2-redirect-port 8080) +(setopt mew-auth-oauth2-client-id mew-oauth2-client-id) +(setopt mew-auth-oauth2-client-secret mew-oauth2-client-secret) +(setopt mew-auth-oauth2-redirect-url mew-oauth2-redirect-url) +(setopt mew-auth-oauth2-redirect-port mew-oauth2-redirect-port) +(setq plstore-cache-passphrase-for-symmetric-encryption t) +(setq epa-file-cache-passphrase-for-symmetric-encryption t) +(setq epa-pinentry-mode 'loopback) (setq mew-config-alist '((Exchange (name "User") @@ -24,13 +34,22 @@ (imap-size 0) (imap-header-only t)) (Gmail + ("oauth2-client-id" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com") + ("oauth2-client-secret" "xxxxxxxxxxxxxxxxxxxxxxxx") + ("oauth2-auth-url" "https://accounts.google.com/o/oauth2/auth") + ("oauth2-token-url" "https://accounts.google.com/o/oauth2/token") + ("oauth2-resource-url" "https://mail.google.com/") + ("oauth2-redirect-url" "http://localhost:8080") + ("oauth2-redirect-port" 8080) + ("imap-auth-list" ("XOAUTH2")) + ("smtp-auth-list" ("XOAUTH2")) (name "User") (user "user") (mail-domain "example.jp") (smtp-server "smtp.gmail.com") (smtp-auth t) (smtp-ssl t) - (smtp-ssl-port 465) + (smtp-ssl-port 587) (smtp-user "user@example.jp") (imap-user "user@example.net") (imap-server "imap.gmail.com") diff --git a/.emacs.d/.mew.d/oauth2/README.md b/.emacs.d/.mew.d/oauth2/README.md deleted file mode 100644 index c706d0c..0000000 --- a/.emacs.d/.mew.d/oauth2/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Mew OAuth2 - -see https://www.rworks.jp/system/system-column/sys-practice/27806/ diff --git a/.emacs.d/.mew.d/oauth2/delegate-auth.php b/.emacs.d/.mew.d/oauth2/delegate-auth.php deleted file mode 100644 index cb040a9..0000000 --- a/.emacs.d/.mew.d/oauth2/delegate-auth.php +++ /dev/null @@ -1,26 +0,0 @@ -\n"; -print "\n"; -print "\n"; -print " \n"; -print " OAuth2 Authorization コードリクエスト\n"; -print "\n"; -print "\n"; - -if ($_GET['p'] != "") { - $url_file = "/tmp/oauth-url." . $_GET['p']; - if (file_exists($url_file)) { - $url = file_get_contents($url_file); - print "

以下にアクセスしてください。

\n"; - print "Authorization コードリクエスト\n"; - unlink($url_file); - } else { - print "

エラー: リクエスト URL を取得できませんでした。もう一度やり直 してください。

\n"; - } -} else { - print "エラー: リクエストが不正です。\n"; -} - -print "\n"; diff --git a/.emacs.d/.mew.d/oauth2/get-auth.php b/.emacs.d/.mew.d/oauth2/get-auth.php deleted file mode 100644 index 4e9196d..0000000 --- a/.emacs.d/.mew.d/oauth2/get-auth.php +++ /dev/null @@ -1,33 +0,0 @@ -\n"; - -if ($_GET['error'] == '') { - $code = $_GET['code']; - if ($code == "" ) { - print "エラー: Authorization コードを取得できませんでした。\n"; - } else { - print "次の Authorization コードを Emacs にコピーしてください。
\n"; - - print ''; - print ''; - print "\n"; - } -} else { - print "エラー: 認証できませんでした。\n"; -} -print "\n"; -?> - - diff --git a/.emacs.d/.mew.d/oauth2/main.tf b/.emacs.d/.mew.d/oauth2/main.tf deleted file mode 100644 index 9686ce1..0000000 --- a/.emacs.d/.mew.d/oauth2/main.tf +++ /dev/null @@ -1,62 +0,0 @@ -# Configure the Azure provider -# see https://learn.microsoft.com/ja-jp/azure/app-service/provision-resource-terraform -terraform { - cloud { - organization = "skirnir" - workspaces { - name = "dotfiles" - } - } - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "~> 4.0.1" - } - } - required_version = ">= 0.14.9" -} -provider "azurerm" { - features {} -} - -# Generate a random integer to create a globally unique name -resource "random_integer" "ri" { - min = 10000 - max = 99999 -} - -# Create the resource group -resource "azurerm_resource_group" "rg" { - name = "mew-oauth2" - location = "japaneast" -} - -# Create the Linux App Service Plan -resource "azurerm_service_plan" "appserviceplan" { - name = "mew-oauth2" - location = azurerm_resource_group.rg.location - resource_group_name = azurerm_resource_group.rg.name - os_type = "Linux" - sku_name = "F1" -} - -# Create the web app, pass in the App Service Plan ID -resource "azurerm_linux_web_app" "webapp" { - name = "mew-oauth2" - location = azurerm_resource_group.rg.location - resource_group_name = azurerm_resource_group.rg.name - service_plan_id = azurerm_service_plan.appserviceplan.id - https_only = true - site_config { - minimum_tls_version = "1.2" - } -} - -# Deploy code from a public GitHub repo -resource "azurerm_app_service_source_control" "sourcecontrol" { - app_id = azurerm_linux_web_app.webapp.id - repo_url = "https://github.com/nanasess/dotfiles" - branch = "main" - use_manual_integration = true - use_mercurial = false -} diff --git a/.emacs.d/.mew.d/oauth2/request_auth.php b/.emacs.d/.mew.d/oauth2/request_auth.php deleted file mode 100644 index bce1c65..0000000 --- a/.emacs.d/.mew.d/oauth2/request_auth.php +++ /dev/null @@ -1,22 +0,0 @@ -\n"; - -if ($_GET['client_id'] != "" && $_GET['response_type'] != "" && $_GET['scope'] != "") { - $access_url = $AUTHURL . "?"; - foreach($_GET as $name => $value) { - $access_url .= "$name=" . urlencode($value) . "&"; - } - $access_url = rtrim ($access_url, "&"); - $pid = getmypid(); - print "Emacs で OAuth2 を利用する際の Authorization コードを取得します。 -
\n"; - print "以下の URL に手元のブラウザからアクセスしてください。
\n"; - print "/oauth2/delegate-request.php?p=$pid"; - file_put_contents("/tmp/oauth-url." . $pid, $access_url); -} else { - print "エラー: リクエストが不正です。\n"; -} -print "\n"; diff --git a/.emacs.d/el-get.lock b/.emacs.d/el-get.lock index 41756aa..60cb06a 100644 --- a/.emacs.d/el-get.lock +++ b/.emacs.d/el-get.lock @@ -65,7 +65,7 @@ (auto-save-buffers-enhanced :checksum "461e8c816c1b7c650be5f209078b381fe55da8c6") (popwin :checksum "f4bf2e4cbda328359b06d89e233c951cba30363e") (twittering-mode :checksum "114891e8fdb4f06b1326a6cf795e49c205cf9e29") - (mew :checksum "f46b06dba0c7f0aa371be30d704b6d9ba30a8321") + (mew :checksum "70b57878d5f7f9f81ff125b7ce52785ccbe8b46b") (dockerfile-mode :checksum "39a012a27fcf6fb629c447d13b6974baf906714c") (lsp-haskell :checksum "485c1148ce4d27030bb95b21c7289809294e7d31") (haskell-mode :checksum "d23ec34788286405f377ce485d2a17e302d94a4f") diff --git a/.emacs.d/init.el b/.emacs.d/init.el index a7d3456..e329eab 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1035,11 +1035,12 @@ (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)) (el-get-bundle dockerfile-mode) - +(el-get-bundle oauth2 + :type github + :pkgname "emacsmirror/oauth2") (add-to-list 'load-path (concat user-emacs-directory ".mew.d")) (load "mew-config" t t) (setq mew-rc-file ".mew") - (el-get-bundle mew :type github :pkgname "kazu-yamamoto/Mew"