@@ -390,27 +390,48 @@ validate_datetime_in_the_future(Name, State) ->
390390 end
391391 end , Name , State ).
392392
393- is_usage_allowed ({bucket_encryption , " *" }, Req ) ->
393+ is_usage_allowed ({bucket_encryption , " *" }, write , Req ) ->
394+ % % Those who can create a bucket should be able to create a secret to
395+ % % encrypt that bucket
394396 menelaus_auth :has_permission ({[buckets ], create }, Req ) orelse
395397 menelaus_auth :has_permission ({[admin , security ], write }, Req );
396- is_usage_allowed ({bucket_encryption , B }, Req ) ->
398+ is_usage_allowed ({bucket_encryption , " *" }, read , Req ) ->
399+ % % Those who can view bucket list should be able to view the secrets
400+ % % that can encrypt buckets
401+ menelaus_auth :has_permission ({[{bucket , any }, settings ], read }, Req ) orelse
402+ menelaus_auth :has_permission ({[admin , security ], read }, Req );
403+
404+ is_usage_allowed ({bucket_encryption , B }, write , Req ) ->
405+ % % Those who can modify bucket settings should be able to create a secret
406+ % % that encrypts that specific bucket
397407 menelaus_auth :has_permission ({[{bucket , B }, settings ], write }, Req ) orelse
398408 menelaus_auth :has_permission ({[admin , security ], write }, Req );
399- is_usage_allowed (secrets_encryption , Req ) ->
409+ is_usage_allowed ({bucket_encryption , B }, read , Req ) ->
410+ % % Those who can read bucket settings should be able to see secrets that
411+ % % can encrypt that specific bucket
412+ menelaus_auth :has_permission ({[{bucket , B }, settings ], read }, Req ) orelse
413+ menelaus_auth :has_permission ({[admin , security ], read }, Req );
414+
415+ is_usage_allowed (secrets_encryption , write , Req ) ->
416+ menelaus_auth :has_permission ({[admin , security ], write }, Req );
417+ is_usage_allowed (secrets_encryption , read , Req ) ->
418+ menelaus_auth :has_permission ({[admin , security ], read }, Req );
419+
420+ is_usage_allowed (config_encryption , write , Req ) ->
400421 menelaus_auth :has_permission ({[admin , security ], write }, Req );
401- is_usage_allowed (config_encryption , Req ) ->
402- menelaus_auth :has_permission ({[admin , security ], write }, Req ).
422+ is_usage_allowed (config_encryption , read , Req ) ->
423+ menelaus_auth :has_permission ({[admin , security ], read }, Req ).
403424
404425read_filter_secrets_by_permission (Secrets , Req ) ->
405426 lists :filter (
406427 fun (#{usage := List }) when List /= [] ->
407- lists :any (is_usage_allowed (_ , Req ), List )
428+ lists :any (is_usage_allowed (_ , read , Req ), List )
408429 end , Secrets ).
409430
410431write_filter_secrets_by_permission (Secrets , Req ) ->
411432 lists :filter (
412433 fun (#{usage := List }) when List /= [] ->
413- lists :all (is_usage_allowed (_ , Req ), List )
434+ lists :all (is_usage_allowed (_ , write , Req ), List )
414435 end , Secrets ).
415436
416437parse_id (Str ) when is_list (Str ) ->
0 commit comments