LDAP & PAM added to OAuth password grant strategy (#7999) (#12390)
LDAP & PAM added to OAuth password grant strategy (#7999) (#12390)

When authenticating via OAuth, the resource owner password grant
strategy is allowed by Mastodon, but (without this PR), it does not
attempt to authenticate against LDAP or PAM. As a result, LDAP or PAM
authenticated users cannot sign in to Mastodon with their
email/password credentials via OAuth (for instance, for native/mobile
app users).

This PR fleshes out the authentication strategy supplied to doorkeeper
in its initializer by looking up the user with LDAP and/or PAM when
devise is configured to use LDAP/PAM backends. It attempts to follow the
same logic as the Auth::SessionsController for handling email/password
credentials.

Note #1: Since this pull request affects an initializer, it's unclear
how to add test automation.

Note #2: The PAM authentication path has not been manually tested. It
was added for completeness sake, and it is hoped that it can be manually
tested before merging.
masto-donte-com-br/mastodon,kazh98/social.arnip.org,yi0713/mastodon,Ryanaka/mastodon,pinfort/mastodon,h3zjp/mastodon,musashino205/mastodon,pinfort/mastodon,ikuradon/mastodon,maa123/mastodon,tootcafe/mastodon,glitch-soc/mastodon,imas/mastodon,pinfort/mastodon,MitarashiDango/mastodon,Nyoho/mastodon,MitarashiDango/mastodon,dunn/mastodon,MitarashiDango/mastodon,dunn/mastodon,rainyday/mastodon,kazh98/social.arnip.org,im-in-space/mastodon,rainyday/mastodon,rainyday/mastodon,theoria24/mastodon,lynlynlynx/mastodon,Kirishima21/mastodon,lindwurm/mastodon,koba-lab/mastodon,h3zjp/mastodon,yi0713/mastodon,pinfort/mastodon,primenumber/mastodon,tootcafe/mastodon,dunn/mastodon,primenumber/mastodon,Nyoho/mastodon,tri-star/mastodon,lindwurm/mastodon,musashino205/mastodon,Nyoho/mastodon,dunn/mastodon,maa123/mastodon,yukimochi/mastodon,im-in-space/mastodon,tootsuite/mastodon,imas/mastodon,lynlynlynx/mastodon,MitarashiDango/mastodon,glitch-soc/mastodon,im-in-space/mastodon,kirakiratter/mastodon,gol-cha/mastodon,glitch-soc/mastodon,cobodo/mastodon,Kirishima21/mastodon,danhunsaker/mastodon,ikuradon/mastodon,masto-donte-com-br/mastodon,musashino205/mastodon,tri-star/mastodon,cobodo/mastodon,primenumber/mastodon,imas/mastodon,tootsuite/mastodon,ykzts/mastodon,yukimochi/mastodon,abcang/mastodon,Kirishima21/mastodon,kirakiratter/mastodon,Ryanaka/mastodon,masto-donte-com-br/mastodon,kazh98/social.arnip.org,yukimochi/mastodon,tri-star/mastodon,danhunsaker/mastodon,Ryanaka/mastodon,masto-donte-com-br/mastodon,glitch-soc/mastodon,cobodo/mastodon,koba-lab/mastodon,ykzts/mastodon,gol-cha/mastodon,tri-star/mastodon,ikuradon/mastodon,ikuradon/mastodon,lindwurm/mastodon,lynlynlynx/mastodon,maa123/mastodon,yi0713/mastodon,Kirishima21/mastodon,ykzts/mastodon,abcang/mastodon,maa123/mastodon,koba-lab/mastodon,im-in-space/mastodon,abcang/mastodon,ykzts/mastodon,cobodo/mastodon,koba-lab/mastodon,yukimochi/mastodon,musashino205/mastodon,gol-cha/mastodon,h3zjp/mastodon,yi0713/mastodon,tootcafe/mastodon,lindwurm/mastodon,primenumber/mastodon,theoria24/mastodon,imas/mastodon,Nyoho/mastodon,kirakiratter/mastodon,tootsuite/mastodon,kirakiratter/mastodon,abcang/mastodon,kazh98/social.arnip.org,theoria24/mastodon,Ryanaka/mastodon,danhunsaker/mastodon,lynlynlynx/mastodon,gol-cha/mastodon,danhunsaker/mastodon,h3zjp/mastodon,rainyday/mastodon,theoria24/mastodon,tootsuite/mastodon,tootcafe/mastodon