package com.atlassian.bitbucket.internal.mirroring.upstream.auth;

import com.atlassian.bitbucket.internal.mirroring.auth.Credentials;
import com.atlassian.bitbucket.internal.mirroring.user.ApplicationUserWithPermissions;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Authenticates a user with the supplied credentials. This supports the REST endpoint which allows mirror servers
 * to authenticate on the upstream server on behalf of their users.
 */
public interface AuthenticationService {
    /**
     * Authenticates a user with the supplied credentials
     * @param credentials the credentials
     * @return a {@link ApplicationUserWithPermissions user with permissions} if the credentials are valid, null otherwise
     */
    @Nullable
    ApplicationUserWithPermissions authenticateForUser(@Nonnull Credentials credentials);
}
