Those of us who live in the Western world would reject the idea that justice depends on what the laws say. Instead, we typically believe in the idea of natural rights. We believe, as the Declaration of Independence says, that we all have “certain unalienable rights” by virtue of the fact that we are human. Actions that violate these laws are unjust, regardless of what the laws made by the government say.
We can see that this is true from various events in our history. For example, for the first 90 years of our country’s existence, slavery was not banned by the Constitution and was supported by the laws of many states (and by some national laws like the Fugitive Slave Act). After the Reconstruction Era, many states also had laws enforcing segregation and denying African Americans the right to vote. Today, we would not argue that any of these laws were just. They were all unjust laws that existed simply because people are not always just.
These examples show clearly that justice and injustice are not the same things as legality and illegality. There are certain rights that we all have as people. Laws that protect these rights are just. Laws that infringe on those rights are unjust, even if they have been passed by all the proper and legal procedures.