From ecc606b87dc9507387c4ccecd83cbe6e7a970301 Mon Sep 17 00:00:00 2001 From: Thomas Abraham Date: Wed, 8 Dec 2021 16:53:36 +0100 Subject: [PATCH 1/5] Supporting team in authorization of event-types and subscriptions --- client/Helpers/AccessEditor.elm | 9 +++++++++ server/config.js | 1 + tests/unit/config.spec.js | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/client/Helpers/AccessEditor.elm b/client/Helpers/AccessEditor.elm index e99da4a..f5d4e3e 100644 --- a/client/Helpers/AccessEditor.elm +++ b/client/Helpers/AccessEditor.elm @@ -42,6 +42,7 @@ type alias Model = type alias Config = { appsInfoUrl : String , usersInfoUrl : String + , teamsInfoUrl : String , showWrite : Bool , showAnyToken : Bool , help : List (Html Msg) @@ -344,6 +345,9 @@ addRowControls config model = "service" -> "Service Id with '" ++ appPreffix ++ "' prefix, i.e. '" ++ appPreffix ++ "_shop'" + "team" -> + "Team Id in teams API, e.g. 'aruha'" + _ -> "Value" in @@ -356,6 +360,7 @@ addRowControls config model = ] [ option [ value "user" ] [ text "User" ] , option [ value "service" ] [ text "Service" ] + , option [ value "team" ] [text "Team" ] ] , input [ onInput AddValueChange @@ -420,6 +425,7 @@ accessTable config renderer records = [] , renderSection User "Users:" , renderSection Service "Services:" + , renderSection Team "Teams:" , renderSection Unknown "Unknown types:" ] ) @@ -492,6 +498,9 @@ recordName config record = Service -> span [ class "access-editor_name" ] [ UI.linkToApp config.appsInfoUrl record.value ] + Team -> + span [ class "access-editor_name" ] [ UI.linkToApp config.teamsInfoUrl record.value ] + User -> span [ class "access-editor_name" ] [ UI.linkToApp config.usersInfoUrl record.value ] diff --git a/server/config.js b/server/config.js index 7fd7333..de4abfd 100644 --- a/server/config.js +++ b/server/config.js @@ -28,6 +28,7 @@ exports = module.exports = function createConfiguration(env) { settings: { appsInfoUrl: optional('APPS_INFO_URL', env, ''), usersInfoUrl: optional('USERS_INFO_URL', env, ''), + teamsInfoUrl: optional('TEAMS_INFO_URL', env, ''), nakadiApiUrl: required('NAKADI_API_URL', env), monitoringUrl: optional('MONITORING_URL', env, ''), sloMonitoringUrl: optional('SLO_MONITORING_URL', env, ''), diff --git a/tests/unit/config.spec.js b/tests/unit/config.spec.js index aada548..14a6657 100644 --- a/tests/unit/config.spec.js +++ b/tests/unit/config.spec.js @@ -10,6 +10,7 @@ describe('Config', function() { NAKADI_API_URL: "https://nakadi-staging.example.com", APPS_INFO_URL: "https://yourturn.example.com", USERS_INFO_URL: "https://people.example.com", + TEAMS_INFO_URL: "https://teams-api.example.com", MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-staging", SLO_MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-slos", EVENT_TYPE_MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-et/?var-stack=nakadi-staging&var-et={et}", @@ -62,6 +63,7 @@ describe('Config', function() { settings: { appsInfoUrl: "https://yourturn.example.com", usersInfoUrl: "https://people.example.com", + teamsInfoUrl: "https://teams-api.example.com", nakadiApiUrl: 'https://nakadi-staging.example.com', monitoringUrl: "https://zmon.example.com/grafana/dashboard/db/nakadi-staging", sloMonitoringUrl: "https://zmon.example.com/grafana/dashboard/db/nakadi-slos", @@ -123,6 +125,7 @@ describe('Config', function() { BASE_URL: "https://localhost:3000", APPS_INFO_URL: "https://yourturn.example.com", USERS_INFO_URL: "https://people.example.com", + TEAMS_INFO_URL: "https://teams-api.example.com", // this is missing for example // NAKADI_API_URL: "https://nakadi-staging.example.com", MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-staging", @@ -153,6 +156,7 @@ describe('Config', function() { NAKADI_API_URL: "https://nakadi-staging.example.com", USERS_INFO_URL: "https://people.example.com", APPS_INFO_URL: "https://yourturn.example.com", + TEAMS_INFO_URL: "https://teams-api.example.com", MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-staging", SLO_MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-slos", EVENT_TYPE_MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-et/?var-stack=nakadi-staging&var-et={et}", @@ -180,6 +184,7 @@ describe('Config', function() { NAKADI_API_URL: "https://nakadi-staging.example.com", APPS_INFO_URL: "https://yourturn.example.com", USERS_INFO_URL: "https://people.example.com", + TEAMS_INFO_URL: "https://teams-api.example.com", MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-staging", SLO_MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-slos", EVENT_TYPE_MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-et/?var-stack=nakadi-staging&var-et={et}", @@ -206,6 +211,7 @@ describe('Config', function() { NAKADI_API_URL: "https://nakadi-staging.example.com", APPS_INFO_URL: "https://yourturn.example.com", USERS_INFO_URL: "https://people.example.com", + TEAMS_INFO_URL: "https://teams-api.example.com", MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-staging", SLO_MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-slos", EVENT_TYPE_MONITORING_URL: "https://zmon.example.com/grafana/dashboard/db/nakadi-et/?var-stack=nakadi-staging&var-et={et}", From db0bed8fe15cd2ca6cc5a99a124ff0801a648c07 Mon Sep 17 00:00:00 2001 From: Thomas Abraham Date: Wed, 8 Dec 2021 17:06:35 +0100 Subject: [PATCH 2/5] Fixing : File is not formatted with elm-format-0.8.1 --- client/Helpers/AccessEditor.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/Helpers/AccessEditor.elm b/client/Helpers/AccessEditor.elm index f5d4e3e..9d2796f 100644 --- a/client/Helpers/AccessEditor.elm +++ b/client/Helpers/AccessEditor.elm @@ -360,7 +360,7 @@ addRowControls config model = ] [ option [ value "user" ] [ text "User" ] , option [ value "service" ] [ text "Service" ] - , option [ value "team" ] [text "Team" ] + , option [ value "team" ] [ text "Team" ] ] , input [ onInput AddValueChange From 5ebcbc717b07abaf20398beeea7d8bdc84730b78 Mon Sep 17 00:00:00 2001 From: Thomas Abraham Date: Thu, 9 Dec 2021 08:54:35 +0100 Subject: [PATCH 3/5] Adding Team to Authorization.elm --- client/Stores/Authorization.elm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/Stores/Authorization.elm b/client/Stores/Authorization.elm index 7e326e4..b360139 100644 --- a/client/Stores/Authorization.elm +++ b/client/Stores/Authorization.elm @@ -16,6 +16,7 @@ type alias AuthorizationAttribute = type Key = User | Service + | Team | All | Unknown @@ -179,6 +180,9 @@ dataTypeToKey str = "service" -> Service + "team" -> + Team + "*" -> All From bfe0e12ba99342de08e9080871ca152aeb5db691 Mon Sep 17 00:00:00 2001 From: Thomas Abraham Date: Thu, 9 Dec 2021 09:15:41 +0100 Subject: [PATCH 4/5] Adding teamsInfoUrl where required --- client/Pages/EventTypeCreate/Query.elm | 1 + client/Pages/EventTypeCreate/View.elm | 4 ++++ client/Pages/EventTypeDetails/View.elm | 4 ++++ client/Pages/SubscriptionCreate/View.elm | 4 ++++ client/Pages/SubscriptionDetails/View.elm | 4 ++++ client/User/Models.elm | 2 ++ 6 files changed, 19 insertions(+) diff --git a/client/Pages/EventTypeCreate/Query.elm b/client/Pages/EventTypeCreate/Query.elm index 3e124f4..f77e30f 100644 --- a/client/Pages/EventTypeCreate/Query.elm +++ b/client/Pages/EventTypeCreate/Query.elm @@ -207,6 +207,7 @@ sqlAccessEditor appsInfoUrl usersInfoUrl formModel = AccessEditor.view { appsInfoUrl = appsInfoUrl , usersInfoUrl = usersInfoUrl + , teamsInfoUrl = "" , showWrite = False , showAnyToken = False , help = Help.authorization diff --git a/client/Pages/EventTypeCreate/View.elm b/client/Pages/EventTypeCreate/View.elm index a4c6fd8..fff6b52 100644 --- a/client/Pages/EventTypeCreate/View.elm +++ b/client/Pages/EventTypeCreate/View.elm @@ -231,6 +231,9 @@ viewForm model setup = usersInfoUrl = model.userStore.user.settings.usersInfoUrl + teamsInfoUrl = + model.userStore.user.settings.teamsInfoUrl + supportUrl = model.userStore.user.settings.supportUrl @@ -449,6 +452,7 @@ accessEditor appsInfoUrl usersInfoUrl formModel = AccessEditor.view { appsInfoUrl = appsInfoUrl , usersInfoUrl = usersInfoUrl + , teamsInfoUrl = teamsInfoUrl , showWrite = True , showAnyToken = True , help = Help.authorization diff --git a/client/Pages/EventTypeDetails/View.elm b/client/Pages/EventTypeDetails/View.elm index 57c6a86..6825988 100644 --- a/client/Pages/EventTypeDetails/View.elm +++ b/client/Pages/EventTypeDetails/View.elm @@ -94,6 +94,9 @@ detailsLayout typeName eventType model = usersInfoUrl = settings.usersInfoUrl + teamsInfoUrl = + settings.teamsInfoUrl + showNakadiSql = settings.showNakadiSql @@ -769,6 +772,7 @@ authTab appsInfoUrl usersInfoUrl eventType = [ AccessEditor.viewReadOnly { appsInfoUrl = appsInfoUrl , usersInfoUrl = usersInfoUrl + , teamsInfoUrl = teamsInfoUrl , showWrite = True , showAnyToken = True , help = Help.authorization diff --git a/client/Pages/SubscriptionCreate/View.elm b/client/Pages/SubscriptionCreate/View.elm index 1298d59..2217532 100644 --- a/client/Pages/SubscriptionCreate/View.elm +++ b/client/Pages/SubscriptionCreate/View.elm @@ -110,6 +110,9 @@ viewForm model setup = usersInfoUrl = model.userStore.user.settings.usersInfoUrl + teamsInfoUrl = + model.userStore.user.settings.teamsInfoUrl + cursosId = "subscriptionCursorFileSelector" in @@ -217,6 +220,7 @@ accessEditor appsInfoUrl usersInfoUrl formModel = AccessEditor.view { appsInfoUrl = appsInfoUrl , usersInfoUrl = usersInfoUrl + , teamsInfoUrl = teamsInfoUrl , showWrite = False , showAnyToken = True , help = Help.authorization diff --git a/client/Pages/SubscriptionDetails/View.elm b/client/Pages/SubscriptionDetails/View.elm index bf0a299..e980c8c 100644 --- a/client/Pages/SubscriptionDetails/View.elm +++ b/client/Pages/SubscriptionDetails/View.elm @@ -77,6 +77,9 @@ detailsLayout id subscription model = usersInfoUrl = model.userStore.user.settings.usersInfoUrl + teamsInfoUrl = + model.userStore.user.settings.teamsInfoUrl + tabOptions = { onChange = \tab -> TabChange tab , notSelectedView = Just (div [] [ text "No tab selected" ]) @@ -472,6 +475,7 @@ authTab appsInfoUrl usersInfoUrl subscription = [ AccessEditor.viewReadOnly { appsInfoUrl = appsInfoUrl , usersInfoUrl = usersInfoUrl + , teamsInfoUrl = teamsInfoUrl , showWrite = False , showAnyToken = True , help = Help.authorization diff --git a/client/User/Models.elm b/client/User/Models.elm index c866a7c..75813dd 100644 --- a/client/User/Models.elm +++ b/client/User/Models.elm @@ -45,6 +45,7 @@ type alias Settings = { nakadiApiUrl : String , appsInfoUrl : String , usersInfoUrl : String + , teamsInfoUrl : String , monitoringUrl : String , sloMonitoringUrl : String , eventTypeMonitoringUrl : String @@ -67,6 +68,7 @@ initialSettings = { nakadiApiUrl = emptyString , appsInfoUrl = emptyString , usersInfoUrl = emptyString + , teamsInfoUrl = emptyString , monitoringUrl = emptyString , sloMonitoringUrl = emptyString , eventTypeMonitoringUrl = emptyString From 0b134f8d30bf80b81818aa60bcc52ebc6611227a Mon Sep 17 00:00:00 2001 From: Thomas Abraham Date: Thu, 9 Dec 2021 09:23:50 +0100 Subject: [PATCH 5/5] teamsInfoUrl in more places --- client/Pages/EventTypeCreate/View.elm | 6 +++--- client/Pages/EventTypeDetails/View.elm | 5 +++-- client/Pages/SubscriptionCreate/View.elm | 6 +++--- client/Pages/SubscriptionDetails/View.elm | 5 +++-- client/User/Commands.elm | 1 + 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/client/Pages/EventTypeCreate/View.elm b/client/Pages/EventTypeCreate/View.elm index fff6b52..2e9f3f1 100644 --- a/client/Pages/EventTypeCreate/View.elm +++ b/client/Pages/EventTypeCreate/View.elm @@ -435,7 +435,7 @@ viewForm model setup = compatibilityModeOptions , schemaEditor formModel , hr [ class "dc-divider" ] [] - , accessEditor appsInfoUrl usersInfoUrl formModel + , accessEditor appsInfoUrl usersInfoUrl teamsInfoUrl formModel ] , hr [ class "dc-divider" ] [] @@ -447,8 +447,8 @@ viewForm model setup = ] -accessEditor : String -> String -> Model -> Html Msg -accessEditor appsInfoUrl usersInfoUrl formModel = +accessEditor : String -> String -> String -> Model -> Html Msg +accessEditor appsInfoUrl usersInfoUrl teamsInfoUrl formModel = AccessEditor.view { appsInfoUrl = appsInfoUrl , usersInfoUrl = usersInfoUrl diff --git a/client/Pages/EventTypeDetails/View.elm b/client/Pages/EventTypeDetails/View.elm index 6825988..c445bd4 100644 --- a/client/Pages/EventTypeDetails/View.elm +++ b/client/Pages/EventTypeDetails/View.elm @@ -260,6 +260,7 @@ detailsLayout typeName eventType model = , authTab appsInfoUrl usersInfoUrl + teamsInfoUrl eventType ) ] @@ -755,8 +756,8 @@ renderSqlQueries query = ] -authTab : String -> String -> EventType -> Html Msg -authTab appsInfoUrl usersInfoUrl eventType = +authTab : String -> String -> String -> EventType -> Html Msg +authTab appsInfoUrl usersInfoUrl teamsInfoUrl eventType = case eventType.authorization of Nothing -> div [ class "dc-card auth-tab" ] diff --git a/client/Pages/SubscriptionCreate/View.elm b/client/Pages/SubscriptionCreate/View.elm index 2217532..7c9f04e 100644 --- a/client/Pages/SubscriptionCreate/View.elm +++ b/client/Pages/SubscriptionCreate/View.elm @@ -205,7 +205,7 @@ viewForm model setup = else none , eventTypesEditor updateMode model - , accessEditor appsInfoUrl usersInfoUrl formModel + , accessEditor appsInfoUrl usersInfoUrl teamsInfoUrl formModel , hr [ class "dc-divider" ] [] , div [ class "dc-toast__content dc-toast__content--success" ] [ text successMessage ] @@ -215,8 +215,8 @@ viewForm model setup = ] -accessEditor : String -> String -> Model -> Html Msg -accessEditor appsInfoUrl usersInfoUrl formModel = +accessEditor : String -> String -> String -> Model -> Html Msg +accessEditor appsInfoUrl usersInfoUrl teamsInfoUrl formModel = AccessEditor.view { appsInfoUrl = appsInfoUrl , usersInfoUrl = usersInfoUrl diff --git a/client/Pages/SubscriptionDetails/View.elm b/client/Pages/SubscriptionDetails/View.elm index e980c8c..7b8bdca 100644 --- a/client/Pages/SubscriptionDetails/View.elm +++ b/client/Pages/SubscriptionDetails/View.elm @@ -170,6 +170,7 @@ detailsLayout id subscription model = , authTab appsInfoUrl usersInfoUrl + teamsInfoUrl subscription ) ] @@ -462,8 +463,8 @@ deletePopup model subscription appsInfoUrl = none -authTab : String -> String -> Subscription -> Html Msg -authTab appsInfoUrl usersInfoUrl subscription = +authTab : String -> String -> String -> Subscription -> Html Msg +authTab appsInfoUrl usersInfoUrl teamsInfoUrl subscription = div [ class "dc-card auth-tab" ] <| case subscription.authorization of Nothing -> diff --git a/client/User/Commands.elm b/client/User/Commands.elm index f963aaa..9156dc6 100644 --- a/client/User/Commands.elm +++ b/client/User/Commands.elm @@ -30,6 +30,7 @@ settingsDecoder = |> required "nakadiApiUrl" string |> optional "appsInfoUrl" string emptyString |> optional "usersInfoUrl" string emptyString + |> optional "teamsInfoUrl" string emptyString |> optional "monitoringUrl" string emptyString |> optional "sloMonitoringUrl" string emptyString |> optional "eventTypeMonitoringUrl" string emptyString