Introduce environment variable KALAMAR_CLIENT_FILE in auth plugin

Change-Id: I00c7058242036c56c34a77a319653d8cf6ad8d1f
diff --git a/Changes b/Changes
index fafbeaa..d8418a1 100755
--- a/Changes
+++ b/Changes
@@ -3,6 +3,8 @@
           assistant. (diewald)
         - Remove deprecated 'auth_support' (since 0.31)
           configuration parameter - use 'Auth' plugin instead. (diewald)
+        - Support environment variable KALAMAR_CLIENT_FILE for
+          client information.
 
 0.47 2022-11-22
         - Add command to generate super_client_info file. (diewald)
diff --git a/lib/Kalamar/Plugin/Auth.pm b/lib/Kalamar/Plugin/Auth.pm
index 5843929..5081ef8 100644
--- a/lib/Kalamar/Plugin/Auth.pm
+++ b/lib/Kalamar/Plugin/Auth.pm
@@ -54,7 +54,8 @@
   };
 
   # Get client_id and client_secret from client file
-  if ($param->{client_file}) {
+  if ($param->{client_file} || $main::ENV{KALAMAR_CLIENT_FILE}) {
+    $param->{client_file} ||= $main::ENV{KALAMAR_CLIENT_FILE};
     my $client_json = decode_json(path($param->{client_file})->slurp);
     $param->{client_id} //= $client_json->{client_id};
     $param->{client_secret} //= $client_json->{client_secret};
diff --git a/t/plugin/auth-oauth.t b/t/plugin/auth-oauth.t
index a2b2039..53358e8 100644
--- a/t/plugin/auth-oauth.t
+++ b/t/plugin/auth-oauth.t
@@ -1004,6 +1004,50 @@
   ->element_exists('aside.settings')
   ;
 
+$main::ENV{KALAMAR_CLIENT_FILE} = $client_file;
+
+$t = Test::Mojo::WithRoles->new('Kalamar' => {
+  Kalamar => {
+    plugins => ['Auth']
+  },
+  'Kalamar-Auth' => {
+    oauth2 => 1,
+#    client_file => $client_file,
+  }
+});
+
+$t->app->plugin(
+  Mount => {
+    $mount_point =>
+      $fixtures_path->child('mock.pl')
+  }
+);
+
+$csrf = $t->get_ok('/')
+  ->status_is(200)
+  ->element_exists_not('div.button.top a')
+  ->tx->res->dom->at('input[name=csrf_token]')->attr('value')
+  ;
+
+$t->post_ok('/user/login' => form => {
+  handle_or_email => 'test',
+  pwd => 'pass',
+  csrf_token => $csrf
+})
+  ->status_is(302)
+  ->header_is('Location' => '/')
+  ->content_is('');
+
+$t->get_ok('/')
+  ->status_is(200)
+  ->element_exists_not('div.notify-error')
+  ->element_exists('div.notify-success')
+  ->text_is('div.notify-success', 'Login successful')
+  ->element_exists_not('aside.off')
+  ->element_exists_not('aside.active')
+  ->element_exists('aside.settings')
+  ;
+
 
 done_testing;
 __END__