re-factored security and BaseEntity