diff --git a/modules/core/docs/authproc_attributemap.txt b/modules/core/docs/authproc_attributemap.txt
index c9daa0b0bf2d90d77349b0a2363289f876b353a5..09364dd514969878e660284dd0c20fb6b96622eb 100644
--- a/modules/core/docs/authproc_attributemap.txt
+++ b/modules/core/docs/authproc_attributemap.txt
@@ -4,7 +4,9 @@
 Filter to change attribute names.
 
 This filter can either contain the name of a map file or a set of name => value pairs describing the transformation.
-If configuration references a map file, the file must be located in the `attributemap/`-directory.
+If configuration references a map file, the file must be located in the `attributemap/` directory in the root of
+SimpleSAMLphp's installation. Attribute map files located in the `attributemap/` directory in the root of a module can
+also be used by specifying the file with the `module:file` syntax.
 
 It can also create multiple attributes from a single attribute by specifying multiple target attributes as an array.
 
@@ -31,7 +33,18 @@ Attribute map in separate file:
         ),
     ),
 
-This filter will use the map file from `simpesamlphp/attributemap/name2oid.php`.
+This filter will use the map file from `simplesamlphp/attributemap/name2oid.php`.
+
+Attribute map in a file contained in a module:
+
+    'authproc' => array(
+        50 => array(
+            'class' => 'core:AttributeMap',
+            'module:src2dst'
+        ),
+    ),
+
+This filter will use the map file from `simplesamlphp/modules/module/attributemap/src2dst.php`.
 
 Duplicate attributes based on a map file:
 
diff --git a/modules/core/lib/Auth/Process/AttributeMap.php b/modules/core/lib/Auth/Process/AttributeMap.php
index 1bcec9fdfcdd6d06a062235012e745027cbdbf67..2f48b62fa2b80e156e3c8cd486ffa591f6cc38d8 100644
--- a/modules/core/lib/Auth/Process/AttributeMap.php
+++ b/modules/core/lib/Auth/Process/AttributeMap.php
@@ -68,14 +68,24 @@ class sspmod_core_Auth_Process_AttributeMap extends SimpleSAML_Auth_ProcessingFi
     /**
      * Loads and merges in a file with a attribute map.
      *
-     * @param string $fileName Name of attribute map file. Expected to be in the attribute map dir.
+     * @param string $fileName Name of attribute map file. Expected to be in the attributemap directory in the root
+     * of the SimpleSAMLphp installation, or in the root of a module.
      *
      * @throws Exception If the filter could not load the requested attribute map file.
      */
     private function loadMapFile($fileName)
     {
         $config = SimpleSAML_Configuration::getInstance();
-        $filePath = $config->getPathValue('attributenamemapdir', 'attributemap/').$fileName.'.php';
+
+        $m = explode(':', $fileName);
+        if (count($m) === 2) { // we are asked for a file in a module
+            if (!SimpleSAML\Module::isModuleEnabled($m[0])) {
+                throw new Exception("Module '$m[0]' is not enabled.");
+            }
+            $filePath = SimpleSAML\Module::getModuleDir($m[0]).'/attributemap/'.$m[1].'.php';
+        } else {
+            $filePath = $config->getPathValue('attributenamemapdir', 'attributemap/').$fileName.'.php';
+        }
 
         if (!file_exists($filePath)) {
             throw new Exception('Could not find attribute map file: '.$filePath);