This is an interesting subject that is often misunderstood. I am not a lawyer, but basically, this is how it works.
1. There are two different Federal labor laws that govern unions. One comes from the Taft-Hartley Act and is adminstered by the National Labor Relations Board (NLRB). [This is the law that the President just used to temporarily end the labor dispute of the west coast dockworkers] This law does not apply to airlines or railroads but applies to everyone else in organized labor.
2. The other law comes from the Railway Labor Act (RLA) and is administered by the National Mediation Board (NMB). Airline pilot labor unions fall under this Federal law.
3. There is no Federal right-to-work law. Those laws are all State laws and do not exist in all States. Where there is conflict, Federal law takes precedence over State law (in general).
The RLA allows basically three types of working situations. For convenience they are called Open Shop, Closed Shop and Agency Shop.
When there is no union or when there is a union whose contract with the employer does not specify one of the other two, you have an Open Shop. In other words, employees do not have to belong to the union and do not have to pay any portion of the union''s dues.
When you have a Closed Shop, membership in the union and therefore the payment of full dues, is required as a condition of employment. If the employee refuses to join the union within a specified period of time and pay dues, the employer is required (by the union's contract) to terminate the employment. To the best of my knowledge only one union representing airline pilots has a Closed Shop. That is the IPA which represents UPS pilots.
The last is the Agency Shop. Some ALPA contracts do NOT contain an Agency Shop provision. Most do. Several Teamster contracts include Agency Shop and so do independents like the APA.
Under Agency Shop, the employee is NOT required to join the union. However, he/she IS required to pay what is known as a "contract maintainence fee". That is an amount less that regular union dues that is supposed to represent the equivalent portion of a member's dues that the union uses exclusively to negotiate and maintain the contract. While it is not madatory, most Agency Shop contracts contain a provision that requires the employer to terminate the employee that refuses to pay his "agency shop fees". It actually happens very rarely in practice as unions are careful about this and most employees pay up at the last minute when challenged.
The amount of Agency Shop fees is determined by the union each year [the law requires this] and the union bills the employee. The bill includes an accounting of the union's use of funds for "representation" and must exclude the sums used for other purposes.
There have been many lawsuits challenging the union's accounting, i.e., calculation of Agency Shop fees. Most have been unsuccessful. However, a significant group of Delta pilots recently won a lawsuit against ALPA at the US Supreme Court level. The litigation is Miller vs ALPA, for those who wish to research it. The Delta pilots were supported in this litigation by an organization in the DC area that more or less specializes in the Anti Agency Shop movement and has funded many lawsuits of this type.
Again, I am not an attorney so don't take what I say as legal advice. This is just my understanding of how the law works.
As far as I know, both Taft-Hartley and the RLA deal with this question in pretty much the same way.
Hope this helps some.