Whenever any action, claim, or proceeding is instituted against any person who is or was an officer, employee, or agent of a port district established under this title arising out of the performance or failure of performance of duties for, or employment with any such district, the commission of the district may grant a request by such person that the attorney of the district's choosing be authorized to defend said claim, suit or proceeding, and the costs of defense, attorney's fees, and any obligation for payment arising from such action may be paid from the district's funds: PROVIDED, That costs of defense and/or judgment or settlement against such person shall not be paid in any case where the court has found that such person was not acting in good faith or within the scope of his or her employment with or duties for the district.