Interfacial boundary conditions determined from empirical or ad-hoc models remain the standard approach to model fluid flows over porous media, even in situations where the topology of the porous medium is known. We propose a non-empirical and accurate method to compute the effective boundary conditions at the interface between a porous surface and an overlying flow. Using multiscale expansion (homogenization) approach, we derive a tensorial generalized version of the empirical condition suggested by Beavers & Joseph (1967). The components of the tensors determining the effective slip velocity at the interface are obtained by solving a set of Stokes equations in a small computational domain near the interface containing both free flow and porous medium. Using the lid-driven cavity flow with a porous bed, we demonstrate that the derived boundary condition is accurate and robust by comparing an effective model to direct numerical simulations. Finally, we provide an open source code that solves the microscale problems and computesthe velocity boundary condition without free parameters over any porous bed.