I have tried giving the user access to a specific project but still, the user is able to access all the project.
If you mean by access the user abiltiy to see issues in a project, then you should make sure that the user does not have browse projects permission for all the projects where the user is not supposed to see issues. He does not have to be in a role or a group to which the permission is granted. More about project permission you can read here:
https://confluence.atlassian.com/adminjiraserver073/managing-project-permissions-861253293.html
It looks like you're new here. Sign in or register to get started.