yesod-auth-smbclient (empty) → 1.0.0.0
raw patch · 4 files changed
+166/−0 lines, 4 filesdep +basedep +hamletdep +sys-auth-smbclientsetup-changed
Dependencies added: base, hamlet, sys-auth-smbclient, text, yesod-auth, yesod-core, yesod-form
Files
- LICENSE +19/−0
- Setup.hs +2/−0
- src/Yesod/Auth/SmbClient.hs +74/−0
- yesod-auth-smbclient.cabal +71/−0
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2013, Kazuo Koga <obiwanko@me.com>++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in+all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Yesod/Auth/SmbClient.hs view
@@ -0,0 +1,74 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes #-}++module Yesod.Auth.SmbClient (authSmbClient) where++import Control.Applicative ((<$>), (<*>))+import Data.Text (Text)+import System.Authenticate.SmbClient (loginSmbClient)+import Text.Hamlet (hamlet)+import Yesod.Auth (+ AuthPlugin(..),+ Creds(..),+ Route(..),+ loginErrorMessage,+ setCreds,+ YesodAuth(..))+import Yesod.Core (+ lift,+ liftIO,+ notFound,+ toWidget)+import Yesod.Form (+ iopt,+ runInputPost,+ textField)++pid = "posixpam"++-- |The smbclient authentication plugin.+authSmbClient :: YesodAuth m =>+ Text -- ^ Server+ -> Text -- ^ Domain+ -> AuthPlugin m+authSmbClient server domain =+ AuthPlugin pid dispatch login+ where+ dispatch "POST" [] = do+ input <- lift $ runInputPost $ (,)+ <$> iopt textField "ident"+ <*> iopt textField "password"+ case input of+ (Just ident, Just password) -> do+ auth <- validate ident password+ either failed success auth+ _ ->+ failed undefined+ dispatch _ _ = notFound++ validate ident password =+ liftIO $ loginSmbClient server domain ident password++ success ident =+ lift $ setCreds True $ Creds pid ident []+ failed _ =+ loginErrorMessage LoginR "Login failed."++ url = PluginR pid []+ login toMaster =+ toWidget [hamlet|+$newline never+ <div #pamlogin>+ <form method=post action=@{toMaster url} .form-horizontal>+ <div .control-group>+ <label .control-label>+ Username+ <div .controls>+ <input type=text name=ident required>+ <div .control-group>+ <label .control-label>+ Password+ <div .controls>+ <input type=password name=password required>+ <div .form-actions>+ <input type=submit .btn .btn-primary value="Login">|]
+ yesod-auth-smbclient.cabal view
@@ -0,0 +1,71 @@+-- For further documentation, see http://haskell.org/cabal/users-guide/++-- The name of the package.+name: yesod-auth-smbclient++-- The package version. See the Haskell package versioning policy (PVP)+-- for standards guiding when and how versions should be incremented.+-- http://www.haskell.org/haskellwiki/Package_versioning_policy+-- PVP summary: +-+------- breaking API changes+-- | | +----- non-breaking API additions+-- | | | +--- code changes with no API change+version: 1.0.0.0++-- A short (one-line) description of the package.+synopsis: Authentication plugin for Yesod using smbclient++-- A longer description of the package.+description: Provides smbclient authentication module that simply+ lets a user specify his/her identifier.++-- The license under which the package is released.+license: MIT++-- The file containing the license text.+license-file: LICENSE++-- The package author(s).+author: Kazuo Koga <obiwanko@me.com>++-- An email address to which users can send suggestions, bug reports, and+-- patches.+maintainer: Kazuo Koga <obiwanko@me.com>++-- A copyright notice.+copyright: (c) 2013 Kazuo Koga <obiwanko@me.com>++homepage: https://github.com/kkazuo/yesod-auth-smbclient.git+bug-reports: https://github.com/kkazuo/yesod-auth-smbclient.git/issues++category: Web, Yesod++build-type: Simple++-- Constraint on the version of Cabal needed to build this package.+cabal-version: >=1.14++library+ default-language: Haskell2010+ hs-source-dirs: src+ ghc-options: -Wall+ -fno-warn-missing-signatures++ -- Modules exported by the library.+ exposed-modules: Yesod.Auth.SmbClient++ -- Modules included in this library but not exported.+ -- other-modules:++ -- Other library packages from which modules are imported.+ build-depends: base <5+ , hamlet+ , sys-auth-smbclient ==2.0.*+ , text+ , yesod-auth+ , yesod-core+ , yesod-form++source-repository this+ type: git+ location: https://github.com/kkazuo/yesod-auth-smbclient.git+ tag: 1.0.0.0