diff --git a/lib/AccountManager/App/Controller.pm b/lib/AccountManager/App/Controller.pm
index 4c86d2def5bef4a3dec9371c07e72b9e8db72975..8f2c9e1a2fd5b73f3745313344fd582abe45e4c9 100644
--- a/lib/AccountManager/App/Controller.pm
+++ b/lib/AccountManager/App/Controller.pm
@@ -66,21 +66,39 @@ sub init_db {
     return $db;
 }
 
-sub check_authentication {
+sub init_user {
     my $self = shift;
 
+    my $headers = $self->req()->headers();
+
     my $idp = 
-        $ENV{'Shib_Identity_Provider'} ||                          # local SP
-        $self->req()->headers()->header('Shib-Identity-Provider'); # remote SP
+        $ENV{'Shib_Identity_Provider'} ||           # local SP
+        $headers->header('Shib-Identity-Provider'); # remote SP
+
+    my $name =
+        $ENV{displayName} ||             # local SP
+        $headers->header('displayName'); # remote SP
+
+    my $user = {
+        idp => $idp,
+        name => $name
+    };
+
+    $self->stash(user => $user);
+
+    return $user;
+}
+
+sub check_authentication {
+    my $self = shift;
 
     return $self->abort(
         status       => 401,
         log_message  => sprintf("unauthenticated user for action %s",  $self->current_route()),
         user_message => Registry::Error::AuthenticationRequired->new()
-    ) if !$idp;
+    ) if !$self->stash('user');
 
     return 1;
-
 }
 
 sub check_token {
diff --git a/lib/AccountManager/App/Step1.pm b/lib/AccountManager/App/Step1.pm
index 77bcac61d515d4a3cd5dc25eae9ee04813b9ec5e..75ea4f2534fb391c8fe95cd7b7dfa91a89efe966 100644
--- a/lib/AccountManager/App/Step1.pm
+++ b/lib/AccountManager/App/Step1.pm
@@ -15,12 +15,14 @@ sub run {
 
     $self->init_db();
     $self->init_l10n();
+    $self->init_user();
 
     if ($config->{app}->{login_url}) {
         return if !$self->check_authentication();
     }
 
-    my $db = $self->stash('db');
+    my $db   = $self->stash('db');
+    my $user = $self->stash('user');
 
     my $sps = AccountManager::Entity->get_entities(
         db    => $db,
@@ -31,12 +33,12 @@ sub run {
     );
 
     my $idp;
-    if ($ENV{HTTP_SHIB_IDENTITY_PROVIDER}) {
+    if ($user) {
         my $idps = AccountManager::Entity->get_entities(
             db    => $db,
             query => [
                 type     => 'idp',
-                entityid => $ENV{HTTP_SHIB_IDENTITY_PROVIDER},
+                entityid => $user->{idp}
             ]
         );
         $idp = $idps->[0];
diff --git a/lib/AccountManager/App/Step2.pm b/lib/AccountManager/App/Step2.pm
index ad46f616f87599f844a74a4e04443cfdd3ac9e9f..eaa3ec644bb404a61c782ab7504739196c42f1a6 100644
--- a/lib/AccountManager/App/Step2.pm
+++ b/lib/AccountManager/App/Step2.pm
@@ -13,6 +13,7 @@ sub run {
 
     $self->init_db();
     $self->init_l10n();
+    $self->init_user();
 
     if ($config->{app}->{login_url}) {
         return if !$self->check_authentication();
diff --git a/lib/AccountManager/App/Step3.pm b/lib/AccountManager/App/Step3.pm
index 20a35bc95cbdef44bda28f4413b0145523ce3f32..3f7c01471321269e7d9041e3e76241598eb39c3f 100644
--- a/lib/AccountManager/App/Step3.pm
+++ b/lib/AccountManager/App/Step3.pm
@@ -20,6 +20,7 @@ sub run {
 
     $self->init_db();
     $self->init_l10n();
+    $self->init_user();
 
     if ($config->{app}->{login_url}) {
         return if !$self->check_authentication();
@@ -29,6 +30,7 @@ sub run {
     my $email    = $self->param('email');
     my $db       = $self->stash('db');
     my $l10n     = $self->stash('l10n');
+    my $user     = $self->stash('user');
 
     my $sp = $self->get_sp(entityid => $entityid);
     return if !$sp;
@@ -103,14 +105,7 @@ sub run {
             $base_templates_dir->child('mail'),
         ]
     });
-    my $user =
-        $ENV{'HTTP_DISPLAYNAME'} ? $ENV{'HTTP_DISPLAYNAME'} :
-        $ENV{'displayName'}      ? $ENV{'displayName'}      :
-        undef;
-    my $idp =
-        $ENV{'HTTP_SHIB_IDENTITY_PROVIDER'} ? $ENV{'HTTP_SHIB_IDENTITY_PROVIDER'} :
-        $ENV{'Shib-Identity-Provider'}      ? $ENV{'Shib-Identity-Provider'}      :
-        undef;
+
     my $data = {
         app => {
             url           => $config->{app}->{url},
@@ -118,9 +113,9 @@ sub run {
             version       => $config->{app}->{version},
             name          => $config->{app}->{name},
         },
-        user          => $user,
+        user          => $user->{name},
         source_ip     => $self->client_ip(),
-        idp           => { entityid => $idp, },
+        idp           => { entityid => $user->{idp}, },
         sp            => { entityid => $entityid, },
         to            => $email,
         token         => $token->secret(),
diff --git a/lib/AccountManager/App/Step4.pm b/lib/AccountManager/App/Step4.pm
index 4a3a29e90e346585356c395fc31fb98f9c21a7fc..b6d50a6e065b506b840927f8d0abe57bcb65ce9a 100644
--- a/lib/AccountManager/App/Step4.pm
+++ b/lib/AccountManager/App/Step4.pm
@@ -21,6 +21,7 @@ sub run {
 
     $self->init_db();
     $self->init_l10n();
+    $self->init_user();
 
     if ($config->{app}->{login_url}) {
         return if !$self->check_authentication();
diff --git a/lib/AccountManager/App/Step5.pm b/lib/AccountManager/App/Step5.pm
index 120d7ad16b1c1e55cf9a65c976a8d7262042d8ff..bec8dd08f52a194458f60b71bc604ab724b27f2e 100644
--- a/lib/AccountManager/App/Step5.pm
+++ b/lib/AccountManager/App/Step5.pm
@@ -21,6 +21,7 @@ sub run {
 
     $self->init_db();
     $self->init_l10n();
+    $self->init_user();
 
     if ($config->{app}->{login_url}) {
         return if !$self->check_authentication();