Correct openapi ignore mode to filter schemas
Also rename openapi-mode options * follow-acl -> follow-privileges * ignore-acl -> ignore-privileges
This commit is contained in:
committed by
Steve Chavez
parent
41d119b19f
commit
f3a184af01
@@ -28,6 +28,7 @@ import System.Posix.Types (FileMode)
|
||||
|
||||
import qualified Data.ByteString.Char8 as BS8
|
||||
import qualified Data.ByteString.Lazy as LBS
|
||||
import qualified Data.HashMap.Strict as Map
|
||||
import qualified Data.Set as Set
|
||||
import qualified Hasql.DynamicStatements.Snippet as SQL
|
||||
import qualified Hasql.Pool as SQL
|
||||
@@ -465,15 +466,15 @@ handleOpenApi :: Bool -> Schema -> RequestContext -> DbHandler Wai.Response
|
||||
handleOpenApi headersOnly tSchema (RequestContext conf@AppConfig{..} dbStructure apiRequest _) = do
|
||||
body <-
|
||||
lift $ case configOpenApiMode of
|
||||
OAFollowACL ->
|
||||
OAFollowPriv ->
|
||||
OpenAPI.encode conf dbStructure
|
||||
<$> SQL.statement tSchema (DbStructure.accessibleTables configDbPreparedStatements)
|
||||
<*> SQL.statement tSchema (DbStructure.accessibleProcs configDbPreparedStatements)
|
||||
<*> SQL.statement tSchema (DbStructure.schemaDescription configDbPreparedStatements)
|
||||
OAIgnoreACL ->
|
||||
OAIgnorePriv ->
|
||||
OpenAPI.encode conf dbStructure
|
||||
(DbStructure.dbTables dbStructure)
|
||||
(DbStructure.dbProcs dbStructure)
|
||||
(filter (\x -> tableSchema x == tSchema) $ DbStructure.dbTables dbStructure)
|
||||
(Map.filterWithKey (\(QualifiedIdentifier sch _) _ -> sch == tSchema) $ DbStructure.dbProcs dbStructure)
|
||||
<$> SQL.statement tSchema (DbStructure.schemaDescription configDbPreparedStatements)
|
||||
OADisabled ->
|
||||
pure mempty
|
||||
|
||||
@@ -192,11 +192,11 @@ exampleConfigFile =
|
||||
|## when none is provided, 660 is applied by default
|
||||
|# server-unix-socket-mode = "660"
|
||||
|
|
||||
|## determine if swagger output should follow or ignore ACL constraints or be disabled entirely
|
||||
|## admitted values: follow-acl, ignore-acl, disabled
|
||||
|openapi-mode = "follow-acl"
|
||||
|## determine if the OpenAPI output should follow or ignore role privileges or be disabled entirely
|
||||
|## admitted values: follow-privileges, ignore-privileges, disabled
|
||||
|openapi-mode = "follow-privileges"
|
||||
|
|
||||
|## base url for swagger output
|
||||
|## base url for the OpenAPI output
|
||||
|openapi-server-proxy-uri = ""
|
||||
|
|
||||
|## choose a secret, JSON Web Key (or set) to enable JWT auth
|
||||
|
||||
@@ -103,13 +103,13 @@ instance Show LogLevel where
|
||||
show LogWarn = "warn"
|
||||
show LogInfo = "info"
|
||||
|
||||
data OpenAPIMode = OAFollowACL | OAIgnoreACL | OADisabled
|
||||
data OpenAPIMode = OAFollowPriv | OAIgnorePriv | OADisabled
|
||||
deriving Eq
|
||||
|
||||
instance Show OpenAPIMode where
|
||||
show OAFollowACL = "follow-acl"
|
||||
show OAIgnoreACL = "ignore-acl"
|
||||
show OADisabled = "disabled"
|
||||
show OAFollowPriv = "follow-privileges"
|
||||
show OAIgnorePriv = "ignore-privileges"
|
||||
show OADisabled = "disabled"
|
||||
|
||||
-- | Dump the config
|
||||
toText :: AppConfig -> Text
|
||||
@@ -262,11 +262,11 @@ parser optPath env dbSettings =
|
||||
parseOpenAPIMode :: C.Key -> C.Parser C.Config OpenAPIMode
|
||||
parseOpenAPIMode k =
|
||||
optString k >>= \case
|
||||
Nothing -> pure OAFollowACL
|
||||
Just "follow-acl" -> pure OAFollowACL
|
||||
Just "ignore-acl" -> pure OAIgnoreACL
|
||||
Just "disabled" -> pure OADisabled
|
||||
Just _ -> fail "Invalid openapi-mode. Check your configuration."
|
||||
Nothing -> pure OAFollowPriv
|
||||
Just "follow-privileges" -> pure OAFollowPriv
|
||||
Just "ignore-privileges" -> pure OAIgnorePriv
|
||||
Just "disabled" -> pure OADisabled
|
||||
Just _ -> fail "Invalid openapi-mode. Check your configuration."
|
||||
|
||||
parseOpenAPIServerProxyURI :: C.Key -> C.Parser C.Config (Maybe Text)
|
||||
parseOpenAPIServerProxyURI k =
|
||||
|
||||
Reference in New Issue
Block a user