yesod-auth-oauth2 alternatives and similar packages
Based on the "yesod" category.
Alternatively, view yesod-auth-oauth2 alternatives based on common mentions on social networks and blogs.
-
yesod-persistent
A RESTful Haskell web framework built on WAI. -
yesod-fay
Utilities for using the Fay Haskell-to-JS compiler with Yesod. -
yesod-dsl
A domain specific language and a code generator desined to create RESTful services for managing an RDBMS with Yesod web framework and Persistent. -
yesod-job-queue
Background job queue library for Yesod. -
yesod-crud
Generic administrative CRUD operations as a Yesod subsite -
yesod-auth-hashdb
Yesod.Auth.HashDB plugin, now moved out of main yesod-auth package -
yesod-routes-typescript
generate TypeScript routes for Yesod -
yesod-auth-fb
Authentication backend for Yesod using Facebook. -
yesod-text-markdown
Yesod support for Text.Markdown -
yesod-recaptcha
Dead simple support for reCAPTCHA on Yesod applications. -
yesod-content-pdf
Library for serving PDF content from a Yesod Application -
yesod-comments
Drop-in comments module for a Yesod application -
yesod-goodies
Small utilities useful in any yesod web app -
yesod-form-bootstrap4
yesod-form for bootstrap version 4 -
yesod-worker
Drop-in(ish) background worker system for Yesod applications -
yesod-transloadit
A resuable widget for the Transloadit service & Yesod -
yesod-auth-account-fork
Fork of yesod-auth-account with a few additions -
yesod-raml
Generate Yesod framework route definitions, documentaiton, mock-handler, and more from your RAML spec. -
yesod-auth-kerberos
Kerberos support for Yesod Auth -
yesod-crud-persist
Easy CRUD subsites for yesod with persistent -
yesod-auth-smbclient
Authentication plugin for Yesod using smbclient -
yesod-auth-bcrypt
BCrypt salted and hashed passwords in a database as auth for yesod -
yesod-datatables
Routines for implementing server-side processing for DataTables (jQuery grid) in Haskell -
yesod-auth-ldap-native
Yesod LDAP authentication plugin using native Haskell Ldap.Client -
yesod-fb
Useful glue functions between the fb library and Yesod. -
yesod-auth-hmac-keccak
An account authentication plugin for yesod with encrypted token transfer. -
yesod-auth-zendesk
Zendesk remote authentication support for Yesod apps. -
yesod-pnotify
yet another getMessage/setMessage using pnotify jquery plugins -
yesod-auth-deskcom
Desk.com Multipass support for Yesod apps. -
yesod-test-json
Utility functions for testing JSON web services written in Yesod -
yesod-paypal-rest
Yesod plugin to use PayPal with the paypal-rest-client library. -
yesod-articles
Automatically generate article previews for a yesod site -
yesod-s3
Simple Helper Library for using Amazon's Simple Storage Service (S3) with Yesod
Updating dependencies is time-consuming.
Do you think we are missing an alternative of yesod-auth-oauth2 or a related project?
README
Yesod.Auth.OAuth2
OAuth2 AuthPlugin
s for Yesod.
Usage
import Yesod.Auth
import Yesod.Auth.OAuth2.GitHub
instance YesodAuth App where
-- ...
authPlugins _ = [oauth2GitHub clientId clientSecret]
clientId :: Text
clientId = "..."
clientSecret :: Text
clientSecret = "..."
Some plugins, such as GitHub and Slack, have scoped functions for requesting additional information:
oauth2SlackScoped [SlackBasicScope, SlackEmailScope] clientId clientSecret
Working with Extra Data
We put the minimal amount of user data possible in credsExtra
-- just enough
to support you parsing or fetching additional data yourself.
For example, if you work with GitHub and GitHub user profiles, you likely
already have a model and a way to parse the /user
response. Rather than
duplicate all that in our library, we try to make it easy for you to re-use that
code yourself:
authenticate creds = do
let
-- You can run your own FromJSON parser on the response we already have
eGitHubUser :: Either String GitHubUser
eGitHubUser = getUserResponseJSON creds
-- Avert your eyes, simplified example
Just accessToken = getAccessToken creds
Right githubUser = eGitHubUser
-- Or make followup requests using our access token
runGitHub accessToken $ userRepositories githubUser
-- Or store it for later
insert User
{ userIdent = credsIdent creds
, userAccessToken = accessToken
}
NOTE: Avoid looking up values in credsExtra
yourself; prefer the provided
get
functions. The data representation itself is no longer considered public
API.
Local Providers
If we don't supply a "Provider" (e.g. GitHub, Google, etc) you need, you can
write your own using our provided Prelude
:
import Yesod.Auth.OAuth2.Prelude
pluginName :: Text
pluginName = "mysite"
oauth2MySite :: YesodAuth m => Text -> Text -> AuthPlugin m
oauth2MySite clientId clientSecret =
authOAuth2 pluginName oauth2 $ \manager token -> do
-- Fetch a profile using the manager and token, leave it a ByteString
userResponse <- -- ...
-- Parse it to your preferred identifier, e.g. with Data.Aeson
userId <- -- ...
-- See authGetProfile for the typical case
pure Creds
{ credsPlugin = pluginName
, credsIdent = userId
, credsExtra = setExtra token userResponse
}
where
oauth2 = OAuth2
{ oauthClientId = clientId
, oauthClientSecret = Just clientSecret
, oauthOAuthorizeEndpoint = "https://mysite.com/oauth/authorize"
, oauthAccessTokenEndpoint = "https://mysite.com/oauth/token"
, oauthCallback = Nothing
}
The Prelude
module is considered public API, though we may build something
higher-level that is more convenient for this use-case in the future.
Development & Tests
stack setup
stack build --dependencies-only
stack build --pedantic --test
Please also run HLint and Weeder before submitting PRs.
[CHANGELOG](./CHANGELOG.md) | [LICENSE](./LICENSE)
*Note that all licence references and agreements mentioned in the yesod-auth-oauth2 README section above
are relevant to that project's source code only.