Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Supporting team in authorization of event-types and subscriptions #158

Merged
merged 5 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions client/Helpers/AccessEditor.elm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type alias Model =
type alias Config =
{ appsInfoUrl : String
, usersInfoUrl : String
, teamsInfoUrl : String
, showWrite : Bool
, showAnyToken : Bool
, help : List (Html Msg)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -420,6 +425,7 @@ accessTable config renderer records =
[]
, renderSection User "Users:"
, renderSection Service "Services:"
, renderSection Team "Teams:"
, renderSection Unknown "Unknown types:"
]
)
Expand Down Expand Up @@ -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 ]

Expand Down
1 change: 1 addition & 0 deletions client/Pages/EventTypeCreate/Query.elm
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ sqlAccessEditor appsInfoUrl usersInfoUrl formModel =
AccessEditor.view
{ appsInfoUrl = appsInfoUrl
, usersInfoUrl = usersInfoUrl
, teamsInfoUrl = ""
, showWrite = False
, showAnyToken = False
, help = Help.authorization
Expand Down
10 changes: 7 additions & 3 deletions client/Pages/EventTypeCreate/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -432,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" ]
[]
Expand All @@ -444,11 +447,12 @@ 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
, teamsInfoUrl = teamsInfoUrl
, showWrite = True
, showAnyToken = True
, help = Help.authorization
Expand Down
9 changes: 7 additions & 2 deletions client/Pages/EventTypeDetails/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ detailsLayout typeName eventType model =
usersInfoUrl =
settings.usersInfoUrl

teamsInfoUrl =
settings.teamsInfoUrl

showNakadiSql =
settings.showNakadiSql

Expand Down Expand Up @@ -257,6 +260,7 @@ detailsLayout typeName eventType model =
, authTab
appsInfoUrl
usersInfoUrl
teamsInfoUrl
eventType
)
]
Expand Down Expand Up @@ -752,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" ]
Expand All @@ -769,6 +773,7 @@ authTab appsInfoUrl usersInfoUrl eventType =
[ AccessEditor.viewReadOnly
{ appsInfoUrl = appsInfoUrl
, usersInfoUrl = usersInfoUrl
, teamsInfoUrl = teamsInfoUrl
, showWrite = True
, showAnyToken = True
, help = Help.authorization
Expand Down
10 changes: 7 additions & 3 deletions client/Pages/SubscriptionCreate/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ viewForm model setup =
usersInfoUrl =
model.userStore.user.settings.usersInfoUrl

teamsInfoUrl =
model.userStore.user.settings.teamsInfoUrl

cursosId =
"subscriptionCursorFileSelector"
in
Expand Down Expand Up @@ -202,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 ]
Expand All @@ -212,11 +215,12 @@ 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
, teamsInfoUrl = teamsInfoUrl
, showWrite = False
, showAnyToken = True
, help = Help.authorization
Expand Down
9 changes: 7 additions & 2 deletions client/Pages/SubscriptionDetails/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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" ])
Expand Down Expand Up @@ -167,6 +170,7 @@ detailsLayout id subscription model =
, authTab
appsInfoUrl
usersInfoUrl
teamsInfoUrl
subscription
)
]
Expand Down Expand Up @@ -459,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 ->
Expand All @@ -472,6 +476,7 @@ authTab appsInfoUrl usersInfoUrl subscription =
[ AccessEditor.viewReadOnly
{ appsInfoUrl = appsInfoUrl
, usersInfoUrl = usersInfoUrl
, teamsInfoUrl = teamsInfoUrl
, showWrite = False
, showAnyToken = True
, help = Help.authorization
Expand Down
4 changes: 4 additions & 0 deletions client/Stores/Authorization.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type alias AuthorizationAttribute =
type Key
= User
| Service
| Team
| All
| Unknown

Expand Down Expand Up @@ -179,6 +180,9 @@ dataTypeToKey str =
"service" ->
Service

"team" ->
Team

"*" ->
All

Expand Down
1 change: 1 addition & 0 deletions client/User/Commands.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions client/User/Models.elm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type alias Settings =
{ nakadiApiUrl : String
, appsInfoUrl : String
, usersInfoUrl : String
, teamsInfoUrl : String
, monitoringUrl : String
, sloMonitoringUrl : String
, eventTypeMonitoringUrl : String
Expand All @@ -67,6 +68,7 @@ initialSettings =
{ nakadiApiUrl = emptyString
, appsInfoUrl = emptyString
, usersInfoUrl = emptyString
, teamsInfoUrl = emptyString
, monitoringUrl = emptyString
, sloMonitoringUrl = emptyString
, eventTypeMonitoringUrl = emptyString
Expand Down
1 change: 1 addition & 0 deletions server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ''),
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand All @@ -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}",
Expand Down