Nonfunctional LDAP auth
This commit is contained in:
parent
921e1faca1
commit
94f419394f
@ -19,6 +19,13 @@ stanzas:
|
|||||||
|
|
||||||
ssl: true
|
ssl: true
|
||||||
|
|
||||||
|
forward-env:
|
||||||
|
- LDAPURI
|
||||||
|
- LDAPDN
|
||||||
|
- LDAPPW
|
||||||
|
- LDAPBN
|
||||||
|
- DUMMY_LOGIN
|
||||||
|
|
||||||
# Use the following to automatically copy your bundle upon creation via `yesod
|
# Use the following to automatically copy your bundle upon creation via `yesod
|
||||||
# keter`. Uses `scp` internally, so you can set it to a remote destination
|
# keter`. Uses `scp` internally, so you can set it to a remote destination
|
||||||
# copy-to: user@host:/opt/keter/incoming/
|
# copy-to: user@host:/opt/keter/incoming/
|
||||||
|
|||||||
@ -18,7 +18,7 @@ approot: "_env:APPROOT:http://localhost:3000"
|
|||||||
# reload-templates: false
|
# reload-templates: false
|
||||||
# mutable-static: false
|
# mutable-static: false
|
||||||
# skip-combining: false
|
# skip-combining: false
|
||||||
# auth-dummy-login : false
|
auth-dummy-login: "_env:DUMMY_LOGIN:false"
|
||||||
|
|
||||||
# NB: If you need a numeric value (e.g. 123) to parse as a String, wrap it in single quotes (e.g. "_env:PGPASS:'123'")
|
# NB: If you need a numeric value (e.g. 123) to parse as a String, wrap it in single quotes (e.g. "_env:PGPASS:'123'")
|
||||||
# See https://github.com/yesodweb/yesod/wiki/Configuration#parsing-numeric-values-as-strings
|
# See https://github.com/yesodweb/yesod/wiki/Configuration#parsing-numeric-values-as-strings
|
||||||
@ -32,6 +32,12 @@ database:
|
|||||||
database: "_env:PGDATABASE:uniworx"
|
database: "_env:PGDATABASE:uniworx"
|
||||||
poolsize: "_env:PGPOOLSIZE:10"
|
poolsize: "_env:PGPOOLSIZE:10"
|
||||||
|
|
||||||
|
ldap:
|
||||||
|
uri: "_env:LDAPURI:ldap://localhost:389"
|
||||||
|
dn: "_env:LDAPDN:uniworx"
|
||||||
|
password: "_env:LDAPPW:"
|
||||||
|
basename: "_env:LDAPBN:"
|
||||||
|
|
||||||
cryptoid-keyfile: "_env:CRYPTOID_KEYFILE:cryptoid_key.bf"
|
cryptoid-keyfile: "_env:CRYPTOID_KEYFILE:cryptoid_key.bf"
|
||||||
|
|
||||||
copyright: Insert copyright statement here
|
copyright: Insert copyright statement here
|
||||||
|
|||||||
6
docker/Dockerfile
Normal file
6
docker/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
FROM fpco/stack-build:lts-9.3
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install libldap2-dev libsasl2-dev
|
||||||
@ -72,6 +72,8 @@ dependencies:
|
|||||||
- generic-deriving
|
- generic-deriving
|
||||||
- blaze-html
|
- blaze-html
|
||||||
- conduit-resumablesink >=0.2
|
- conduit-resumablesink >=0.2
|
||||||
|
- yesod-auth-ldap
|
||||||
|
- LDAP
|
||||||
|
|
||||||
# The library contains all of our application code. The executable
|
# The library contains all of our application code. The executable
|
||||||
# defined below is just a thin wrapper.
|
# defined below is just a thin wrapper.
|
||||||
|
|||||||
@ -17,8 +17,10 @@ import Text.Jasmine (minifym)
|
|||||||
|
|
||||||
-- Used only when in "auth-dummy-login" setting is enabled.
|
-- Used only when in "auth-dummy-login" setting is enabled.
|
||||||
import Yesod.Auth.Dummy
|
import Yesod.Auth.Dummy
|
||||||
|
import Yesod.Auth.LDAP
|
||||||
|
|
||||||
|
import LDAP.Data (LDAPScope(..))
|
||||||
|
|
||||||
import Yesod.Auth.OpenId (authOpenId, IdentifierType (Claimed))
|
|
||||||
import Yesod.Default.Util (addStaticContentExternal)
|
import Yesod.Default.Util (addStaticContentExternal)
|
||||||
import Yesod.Core.Types (Logger)
|
import Yesod.Core.Types (Logger)
|
||||||
import qualified Yesod.Core.Unsafe as Unsafe
|
import qualified Yesod.Core.Unsafe as Unsafe
|
||||||
@ -280,12 +282,23 @@ instance YesodAuth UniWorX where
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- You can add other plugins like Google Email, email or OAuth here
|
-- You can add other plugins like Google Email, email or OAuth here
|
||||||
authPlugins app = [authOpenId Claimed []] ++ extraAuthPlugins
|
authPlugins app = [genericAuthLDAP $ ldapConfig app] ++ extraAuthPlugins
|
||||||
-- Enable authDummy login if enabled.
|
-- Enable authDummy login if enabled.
|
||||||
where extraAuthPlugins = [authDummy | appAuthDummyLogin $ appSettings app]
|
where extraAuthPlugins = [authDummy | appAuthDummyLogin $ appSettings app]
|
||||||
|
|
||||||
authHttpManager = getHttpManager
|
authHttpManager = getHttpManager
|
||||||
|
|
||||||
|
ldapConfig :: UniWorX -> LDAPConfig
|
||||||
|
ldapConfig app@(appSettings -> settings) = LDAPConfig
|
||||||
|
{ usernameFilter = ("userPrincipalName=" <>)
|
||||||
|
, identifierModifier = \n _ -> n
|
||||||
|
, ldapUri = appLDAPURI settings
|
||||||
|
, initDN = appLDAPDN settings
|
||||||
|
, initPass = appLDAPPw settings
|
||||||
|
, baseDN = appLDAPBaseName settings
|
||||||
|
, ldapScope = LdapScopeDefault
|
||||||
|
}
|
||||||
|
|
||||||
-- | Access function to determine if a user is logged in.
|
-- | Access function to determine if a user is logged in.
|
||||||
isAuthenticated :: Handler AuthResult
|
isAuthenticated :: Handler AuthResult
|
||||||
isAuthenticated = do
|
isAuthenticated = do
|
||||||
|
|||||||
@ -43,6 +43,11 @@ data AppSettings = AppSettings
|
|||||||
-- ^ Get the IP address from the header when logging. Useful when sitting
|
-- ^ Get the IP address from the header when logging. Useful when sitting
|
||||||
-- behind a reverse proxy.
|
-- behind a reverse proxy.
|
||||||
|
|
||||||
|
, appLDAPURI :: String
|
||||||
|
, appLDAPDN :: String
|
||||||
|
, appLDAPPw :: String
|
||||||
|
, appLDAPBaseName :: Maybe String
|
||||||
|
|
||||||
, appDetailedRequestLogging :: Bool
|
, appDetailedRequestLogging :: Bool
|
||||||
-- ^ Use detailed request logging system
|
-- ^ Use detailed request logging system
|
||||||
, appShouldLogAll :: Bool
|
, appShouldLogAll :: Bool
|
||||||
@ -80,6 +85,9 @@ instance FromJSON AppSettings where
|
|||||||
appPort <- o .: "port"
|
appPort <- o .: "port"
|
||||||
appIpFromHeader <- o .: "ip-from-header"
|
appIpFromHeader <- o .: "ip-from-header"
|
||||||
|
|
||||||
|
( appLDAPURI, appLDAPDN, appLDAPPw, appLDAPBaseName )
|
||||||
|
<- (=<< o .: "ldap") . withObject "LDAP" $ \obj -> (,,,) <$> obj .: "uri" <*> obj .: "dn" <*> obj .: "password" <*> obj .:? "basename"
|
||||||
|
|
||||||
appDetailedRequestLogging <- o .:? "detailed-logging" .!= defaultDev
|
appDetailedRequestLogging <- o .:? "detailed-logging" .!= defaultDev
|
||||||
appShouldLogAll <- o .:? "should-log-all" .!= defaultDev
|
appShouldLogAll <- o .:? "should-log-all" .!= defaultDev
|
||||||
appReloadTemplates <- o .:? "reload-templates" .!= defaultDev
|
appReloadTemplates <- o .:? "reload-templates" .!= defaultDev
|
||||||
|
|||||||
11
stack.yaml
11
stack.yaml
@ -1,6 +1,7 @@
|
|||||||
flags: {}
|
flags: {}
|
||||||
docker:
|
docker:
|
||||||
enable: true
|
enable: true
|
||||||
|
image: uniworx
|
||||||
nix:
|
nix:
|
||||||
enable: false
|
enable: false
|
||||||
packages: []
|
packages: []
|
||||||
@ -13,6 +14,14 @@ packages:
|
|||||||
git: https://github.com/pngwjpgh/zip-stream.git
|
git: https://github.com/pngwjpgh/zip-stream.git
|
||||||
commit: 9272bbed000928d500febad1cdc98d1da29d399e
|
commit: 9272bbed000928d500febad1cdc98d1da29d399e
|
||||||
extra-dep: true
|
extra-dep: true
|
||||||
|
- location:
|
||||||
|
git: https://github.com/mlitchard/yesod-auth-ldap.git
|
||||||
|
commit: 69e08ef687ab96df3352ff4267562135453c6f02
|
||||||
|
extra-dep: true
|
||||||
|
- location:
|
||||||
|
git: https://github.com/mlitchard/authenticate-ldap.git
|
||||||
|
commit: cc2770024766a8fa29d3086688df60aaf65fb954
|
||||||
|
extra-dep: true
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- colonnade-1.1.1
|
- colonnade-1.1.1
|
||||||
- yesod-colonnade-1.1.0
|
- yesod-colonnade-1.1.0
|
||||||
@ -25,4 +34,6 @@ extra-deps:
|
|||||||
|
|
||||||
- encoding-0.8.2
|
- encoding-0.8.2
|
||||||
- regex-compat-0.93.1
|
- regex-compat-0.93.1
|
||||||
|
|
||||||
|
- LDAP-0.6.11
|
||||||
resolver: lts-9.3
|
resolver: lts-9.3
|
||||||
|
|||||||
Reference in New Issue
Block a user