A new electromagnetic two-dimensional guiding center particle in cell (PIC) code is used to investigate the propagation of an Alfven wave in the perpendicular density gradients that characterize the edges of the auroral density cavities. It is shown that the wave planes are strongly distorted by the inhomogeneities of the plasma and that a significant electric field develops in the direction parallel to the background magnetic field during the propagation. This field efficiently accelerates the electrons in the parallel direction, and the incident wave is thus strongly absorbed. The associated dissipation rate is sufficiently strong to explain a complete wave absorption on the density gradients over a fraction of wavelength. The electron parallel acceleration is also characterized. It corresponds to a global parallel acceleration of the electron population. These PIC simulations suggest that the perpendicular density gradients corresponding to the auroral plasma cavities play an important role in the auroral particle acceleration.