Mobile devices use traditional authentication processes, which are vulnerable and unsuitable for highly dynamic environments, such as ubiquitous and pervasive environments. Therefore, new approaches are necessary in such environments. These approaches must be (i) context-aware by considering environmental and operational characteristics, restrictions of devices and information provided by sensors within the pervasive space, and (ii) customizable for balancing the systems proactivity with the control that the user wants to have over his systems. In this paper, it is presented an approach that provides a recommendation system based on the user behavior and the pervasive space where he belongs. The user behavior is defined by the actions and events that compose the activity that is being performed. The experimental results indicate (a) a dynamic and autonomic mechanism, which is more suitable for authenticating users in mobile and pervasive environments, and (b) significant efficiency to detect authentication anomalies by using a similarity model and a spatio-temporal permutation model.