GDPR defines the legal bases companies can use to process personal data. At least one of these conditions must be met, or else the processing is illegal.
The data subject consents to having their data processed. Companies can process a person's data if they consent to it. Consent is only valid if it is informed, affirmative and freely given.
For consent to be informed, the company must clearly explain what it collects and how it will use that data. For consent to be affirmative, the user must take intentional action to show their consent, such as by signing a statement or checking a box. Consent cannot be the default option, so things like pre-checked boxes violate GDPR. For consent to be freely given, the company cannot influence or coerce the subject in any way. The company cannot require consent to use a service unless the processing is necessary for the service to work. For example, a company may need a person's credit card number to sell them something, but it probably doesn't need their IP address.
The company cannot bundle consents if the data is being processed for multiple purposes. The subject must be able to accept or reject each processing activity individually. Organizations must keep records of consent. Subjects can withdraw their consent at any time. If they do, processing must stop.
The data must be processed to execute a contract with the data subject or on the subject's behalf. For example, if someone applies for a loan, the bank may need to process their financial data and employment history.
The controller has a legal obligation to process the data. For example, some healthcare regulations require hospitals to keep patient data on file.
The data must be processed to protect the vital interests of the subject or another person. This refers to situations where data must be processed to save a person's life or prevent harm.
The data must be processed to carry out a task that is in the public interest or part of the controller's official authority. Journalism is a classic example of a public-interest reason for processing personal data. Government agencies can process personal data to exercise their official functions.
The data must be processed to pursue a legitimate interest of the controller or a third party. A legitimate interest is a benefit a company could gain through data processing. Examples include doing background checks on employees or tracking IP addresses on a corporate network for cybersecurity purposes. The processing must be necessary to count as a legitimate interest. A company cannot claim a legitimate interest if it can achieve the task without the data in question. Data subjects must also reasonably expect the processing. If subjects would be surprised to hear that their data is being used a certain way, the company likely doesn't have legitimate interest grounds. The rights of data subjects generally trump a company's legitimate interests.
Organizations must establish and document their bases before collecting data. They must communicate these bases to users. Companies cannot change their bases after the fact without the subject's consent.