Skip to content
Closed
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
10 changes: 7 additions & 3 deletions core/src/main/scala/kafka/admin/AclCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ object AclCommand {

for ((resource, acls) <- resourceToAcl) {
if (acls.isEmpty) {
if (confirmAction(s"Are you sure you want to delete all ACLs for resource `${resource}`? (y/n)"))
if (confirmAction(opts, s"Are you sure you want to delete all ACLs for resource `${resource}`? (y/n)"))
authorizer.removeAcls(resource)
} else {
if (confirmAction(s"Are you sure you want to remove ACLs: $Newline ${acls.map("\t" + _).mkString(Newline)} $Newline from resource `${resource}`? (y/n)"))
if (confirmAction(opts, s"Are you sure you want to remove ACLs: $Newline ${acls.map("\t" + _).mkString(Newline)} $Newline from resource `${resource}`? (y/n)"))
authorizer.removeAcls(acls, resource)
}
}
Expand Down Expand Up @@ -241,7 +241,9 @@ object AclCommand {
resources
}

private def confirmAction(msg: String): Boolean = {
private def confirmAction(opts: AclCommandOptions, msg: String): Boolean = {
if (opts.options.has(opts.yesOpt))
return true
println(msg)
Console.readLine().equalsIgnoreCase("y")
}
Expand Down Expand Up @@ -329,6 +331,8 @@ object AclCommand {

val helpOpt = parser.accepts("help", "Print usage information.")

val yesOpt = parser.accepts("yes", "Assume Yes to all queries and do not prompt.")

val options = parser.parse(args: _*)

def checkArgs() {
Expand Down
4 changes: 1 addition & 3 deletions core/src/test/scala/unit/kafka/admin/AclCommandTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,10 @@ class AclCommandTest extends ZooKeeperTestHarness with Logging {

private def testRemove(resources: Set[Resource], resourceCmd: Array[String], args: Array[String], brokerProps: Properties) {
for (resource <- resources) {
Console.withIn(new StringReader(s"y${AclCommand.Newline}" * resources.size)) {
AclCommand.main(args ++ resourceCmd :+ "--remove")
AclCommand.main(args ++ resourceCmd :+ "--remove" :+ "--yes")
withAuthorizer(brokerProps) { authorizer =>
TestUtils.waitAndVerifyAcls(Set.empty[Acl], authorizer, resource)
}
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions docs/security.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,12 @@ <h4><a id="security_authz_cli" href="#security_authz_cli">Command Line Interface
<td></td>
<td>Convenience</td>
</tr>
<tr>
<td>--yes</td>
<td> Convenience option to assume yes to all queries and do not prompt.</td>
<td></td>
<td>Convenience</td>
</tr>
</tbody></table>

<h4><a id="security_authz_examples" href="#security_authz_examples">Examples</a></h4>
Expand Down