Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App-Lock follow-up #1253

Merged
merged 12 commits into from
Nov 23, 2020
10 changes: 10 additions & 0 deletions services/galley/src/Galley/API/Public.hs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,16 @@ sitemap = do
mkFeatureGetAndPutRoute @'Public.TeamFeatureDigitalSignatures Teams.getDigitalSignaturesInternal Teams.setDigitalSignaturesInternal
mkFeatureGetAndPutRoute @'Public.TeamFeatureAppLock Teams.getAppLockInternal Teams.setAppLockInternal

get "/teams/:tid/features/" (continue Teams.getAllFeaturesH) $
smatting marked this conversation as resolved.
Show resolved Hide resolved
zauthUserId
.&. capture "tid"
.&. accept "application" "json"
document "GET" "getAllFeatures" $ do
summary "Shows the configuration status of every team feature"
parameter Path "tid" bytes' $
description "Team ID"
response 200 "All feature statuses" end

-- Custom Backend API -------------------------------------------------

get "/custom-backend/by-domain/:domain" (continue CustomBackend.getCustomBackendByDomainH) $
Expand Down
33 changes: 33 additions & 0 deletions services/galley/src/Galley/API/Teams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module Galley.API.Teams
internalDeleteBindingTeamWithOneMember,
getFeatureStatus,
setFeatureStatus,
getAllFeaturesH,
getSSOStatusInternal,
setSSOStatusInternal,
getLegalholdStatusInternal,
Expand All @@ -73,6 +74,7 @@ where
import Brig.Types.Team (TeamSize (..))
import Control.Lens
import Control.Monad.Catch
import qualified Data.Aeson as Aeson
import Data.ByteString.Conversion hiding (fromList)
import Data.Id
import qualified Data.Id as Id
Expand All @@ -82,6 +84,7 @@ import Data.List1 (list1)
import Data.Range as Range
import Data.Set (fromList)
import qualified Data.Set as Set
import Data.String.Conversions (cs)
import Data.Time.Clock (UTCTime (..), getCurrentTime)
import qualified Data.UUID as UUID
import qualified Data.UUID.Util as UUID
Expand Down Expand Up @@ -908,6 +911,36 @@ setFeatureStatus setter doauth tid status = do
assertTeamExists tid
setter tid status

getAllFeaturesH :: UserId ::: TeamId ::: JSON -> Galley Response
getAllFeaturesH (uid ::: tid ::: _) =
json <$> getAllFeatures uid tid

getAllFeatures :: UserId -> TeamId -> Galley Aeson.Value
getAllFeatures uid tid = do
Aeson.object
<$> sequence
[ w @'Public.TeamFeatureSSO getSSOStatusInternal,
w @'Public.TeamFeatureLegalHold getLegalholdStatusInternal,
w @'Public.TeamFeatureSearchVisibility getTeamSearchVisibilityAvailableInternal,
w @'Public.TeamFeatureValidateSAMLEmails getValidateSAMLEmailsInternal,
w @'Public.TeamFeatureDigitalSignatures getDigitalSignaturesInternal,
w @'Public.TeamFeatureAppLock getAppLockInternal
]
where
w ::
smatting marked this conversation as resolved.
Show resolved Hide resolved
forall (a :: Public.TeamFeatureName).
( Public.KnownTeamFeatureName a,
Aeson.ToJSON (Public.TeamFeatureStatus a)
) =>
( TeamId ->
Galley (Public.TeamFeatureStatus a)
) ->
Galley (Text, Aeson.Value)
smatting marked this conversation as resolved.
Show resolved Hide resolved
w getter = do
status <- getFeatureStatus @a getter (DoAuth uid) tid
let feature = Public.knownTeamFeatureName @a
pure $ (cs . toByteString' $ feature, Aeson.toJSON status)
fisx marked this conversation as resolved.
Show resolved Hide resolved

getSSOStatusInternal :: TeamId -> Galley (Public.TeamFeatureStatus 'Public.TeamFeatureSSO)
getSSOStatusInternal tid = do
defStatus <- do
Expand Down