From 95440a880b8699e5978e9087cce834a6fe8265af Mon Sep 17 00:00:00 2001 From: Josaphat Imani Date: Sat, 18 May 2024 08:01:58 +0200 Subject: [PATCH] Set OAuth2 default redirect URL --- .env.example | 6 +++--- config/github.php | 2 +- config/oauth2.php | 17 ++++++----------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.env.example b/.env.example index 1779142bcc..de489c7af5 100644 --- a/.env.example +++ b/.env.example @@ -145,14 +145,14 @@ DYNAMIC_MAIL_SUBDOMAIN="" #github.com GITHUB_CLIENT_ID= GITHUB_CLIENT_SECRET= -GITHUB_REDIRECT_URI= +GITHUB_REDIRECT_URI=http://localhost/?page=home GITHUB_AUTH_URL=https://github.com/login/oauth/authorize GITHUB_AUTH_URL=https://github.com/login/oauth/access_token #gmail GMAIL_CLIENT_ID= GMAIL_CLIENT_SECRET= -GMAIL_CLIENT_URI= +GMAIL_CLIENT_URI=http://localhost/?page=home GMAIL_AUTH_URI=https://accounts.google.com/o/oauth2/auth GMAIL_TOKEN_URI=https://www.googleapis.com/oauth2/v3/token GMAIL_REFRESH_URI=https://www.googleapis.com/oauth2/v3/token @@ -160,7 +160,7 @@ GMAIL_REFRESH_URI=https://www.googleapis.com/oauth2/v3/token #aoutlook OUTLOOK_CLIENT_ID= OUTLOOK_CLIENT_SECRET= -OUTLOOK_CLIENT_URI= +OUTLOOK_CLIENT_URI=http://localhost/?page=home OUTLOOK_AUTH_URI=https://login.live.com/oauth20_authorize.srf OUTLOOK_TOKEN_URI=https://login.live.com/oauth20_token.srf OUTLOOK_REFRESH_URI=https://login.live.com/oauth20_token.srf diff --git a/config/github.php b/config/github.php index a0c5f12bcf..1a9af8f9c9 100644 --- a/config/github.php +++ b/config/github.php @@ -16,7 +16,7 @@ 'github' => [ 'client_id' => env('GITHUB_CLIENT_ID', ''), 'client_secret' => env('GITHUB_CLIENT_SECRET', ''), - 'redirect_uri' => env('GITHUB_REDIRECT_URI', ''), + 'redirect_uri' => env('GITHUB_REDIRECT_URI', 'http://localhost/?page=home'), 'auth_url' => env('GITHUB_AUTH_URL', 'https://github.com/login/oauth/authorize'), 'token_url' => env('GITHUB_TOKEN_URL', 'https://github.com/login/oauth/access_token'), ], diff --git a/config/oauth2.php b/config/oauth2.php index aab449025f..35c3912803 100644 --- a/config/oauth2.php +++ b/config/oauth2.php @@ -6,20 +6,15 @@ | Constants used for oauth2 authentication over IMAP | ------------------------------------------------- | - | Once you edit this file, you must move it to the directory defined by - | app_data_dir in your config/app.php file. No need to re-run the - | config_gen.php script. - | - | Do not forget to add the service to $services = ['gmail', 'outlook']; in - | oauth2_setup function from modules/nux/modules.php - | - | SECURITY ALERT ! MAKE SURE THAT THIS FILE IS NOT ACCESSIBLE BY THE BROWSER ! - | | Currently there are only two popular E-mail providers supporting IMAP/oauth2, | Outlook and Gmail. In order to use oauth2 you must create a web application | that generates a client id, client secret and a redirect URI, then define them | in this file. | + | An OAuth2 app can connect multiple accounts by using the user's authorization + | to request unique access tokens for each account during the OAuth2 flow. + | Each token corresponds to a specific user's permissions and account data. + | | Outlook.com https://account.live.com/developers/applications/ | Gmail: https://console.developers.google.com/project | @@ -29,7 +24,7 @@ 'gmail' => [ 'client_id' => env('GMAIL_CLIENT_ID', ''), 'client_secret' => env('GMAIL_CLIENT_SECRET', ''), - 'client_uri' => env('GMAIL_CLIENT_URI', ''), + 'client_uri' => env('GMAIL_CLIENT_URI', 'http://localhost/?page=home'), 'auth_uri' => env('GMAIL_AUTH_URI', 'https://accounts.google.com/o/oauth2/auth'), 'token_uri' => env('GMAIL_TOKEN_URI', 'https://www.googleapis.com/oauth2/v3/token'), 'refresh_uri' => env('GMAIL_REFRESH_URI', 'https://www.googleapis.com/oauth2/v3/token') @@ -39,7 +34,7 @@ 'outlook' => [ 'client_id' => env('OUTLOOK_CLIENT_ID', ''), 'client_secret' => env('OUTLOOK_CLIENT_SECRET', ''), - 'client_uri' => env('OUTLOOK_CLIENT_URI', ''), + 'client_uri' => env('OUTLOOK_CLIENT_URI', 'http://localhost/?page=home'), 'auth_uri' => env('OUTLOOK_AUTH_URI', 'https://login.live.com/oauth20_authorize.srf'), 'token_uri' => env('OUTLOOK_TOKEN_URI', 'https://login.live.com/oauth20_token.srf'), 'refresh_uri' => env('OUTLOOK_REFRESH_URI', 'https://login.live.com/oauth20_token.srf')