diff --git a/src/main/resources/update/gitbucket-core_4.11.xml b/src/main/resources/update/gitbucket-core_4.11.xml
index 24f1f43..1c41d88 100644
--- a/src/main/resources/update/gitbucket-core_4.11.xml
+++ b/src/main/resources/update/gitbucket-core_4.11.xml
@@ -6,6 +6,7 @@
+
diff --git a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala
index 303cd56..b396e4b 100644
--- a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala
+++ b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala
@@ -58,11 +58,12 @@
// for deploy key
- case class DeployKeyForm(title: String, publicKey: String)
+ case class DeployKeyForm(title: String, publicKey: String, allowWrite: Boolean)
val deployKeyForm = mapping(
- "title" -> trim(label("Title", text(required, maxlength(100)))),
- "publicKey" -> trim(label("Key" , text(required)))
+ "title" -> trim(label("Title", text(required, maxlength(100)))),
+ "publicKey" -> trim(label("Key" , text(required))), // TODO duplication check in the repository?
+ "allowWrite" -> trim(label("Key" , boolean()))
)(DeployKeyForm.apply)
// for web hook url addition
@@ -391,7 +392,7 @@
/** Register a deploy key */
post("/:owner/:repository/settings/deploykey", deployKeyForm)(ownerOnly { (form, repository) =>
- addDeployKey(repository.owner, repository.name, form.title, form.publicKey)
+ addDeployKey(repository.owner, repository.name, form.title, form.publicKey, form.allowWrite)
redirect(s"/${repository.owner}/${repository.name}/settings/deploykey")
})
diff --git a/src/main/scala/gitbucket/core/model/DeployKey.scala b/src/main/scala/gitbucket/core/model/DeployKey.scala
index 829f256..4f34e45 100644
--- a/src/main/scala/gitbucket/core/model/DeployKey.scala
+++ b/src/main/scala/gitbucket/core/model/DeployKey.scala
@@ -11,7 +11,8 @@
val deployKeyId = column[Int]("DEPLOY_KEY_ID", O AutoInc)
val title = column[String]("TITLE")
val publicKey = column[String]("PUBLIC_KEY")
- def * = (userName, repositoryName, deployKeyId, title, publicKey) <> (DeployKey.tupled, DeployKey.unapply)
+ val allowWrite = column[Boolean]("ALLOW_WRITE")
+ def * = (userName, repositoryName, deployKeyId, title, publicKey, allowWrite) <> (DeployKey.tupled, DeployKey.unapply)
def byPrimaryKey(userName: String, repositoryName: String, deployKeyId: Int) =
(this.userName === userName.bind) && (this.repositoryName === repositoryName.bind) && (this.deployKeyId === deployKeyId.bind)
@@ -23,5 +24,6 @@
repositoryName: String,
deployKeyId: Int = 0,
title: String,
- publicKey: String
+ publicKey: String,
+ allowWrite: Boolean
)
diff --git a/src/main/scala/gitbucket/core/service/DeployKeyService.scala b/src/main/scala/gitbucket/core/service/DeployKeyService.scala
index 998c572..7313bc6 100644
--- a/src/main/scala/gitbucket/core/service/DeployKeyService.scala
+++ b/src/main/scala/gitbucket/core/service/DeployKeyService.scala
@@ -6,11 +6,20 @@
trait DeployKeyService {
- def addDeployKey(userName: String, repositoryName: String, title: String, publicKey: String)(implicit s: Session): Unit =
- DeployKeys.insert(DeployKey(userName = userName, repositoryName = repositoryName, title = title, publicKey = publicKey))
+ def addDeployKey(userName: String, repositoryName: String, title: String, publicKey: String, allowWrite: Boolean)
+ (implicit s: Session): Unit =
+ DeployKeys.insert(DeployKey(
+ userName = userName,
+ repositoryName = repositoryName,
+ title = title,
+ publicKey = publicKey,
+ allowWrite = allowWrite
+ ))
def getDeployKeys(userName: String, repositoryName: String)(implicit s: Session): List[DeployKey] =
- DeployKeys.filter(x => (x.userName === userName.bind) && (x.repositoryName === repositoryName.bind)).sortBy(_.deployKeyId).list
+ DeployKeys
+ .filter(x => (x.userName === userName.bind) && (x.repositoryName === repositoryName.bind))
+ .sortBy(_.deployKeyId).list
def getAllDeployKeys()(implicit s: Session): List[DeployKey] =
DeployKeys.filter(_.publicKey.trim =!= "").list
diff --git a/src/main/twirl/gitbucket/core/account/ssh.scala.html b/src/main/twirl/gitbucket/core/account/ssh.scala.html
index cccfdfe..a8fe812 100644
--- a/src/main/twirl/gitbucket/core/account/ssh.scala.html
+++ b/src/main/twirl/gitbucket/core/account/ssh.scala.html
@@ -30,7 +30,7 @@
diff --git a/src/main/twirl/gitbucket/core/settings/deploykey.scala.html b/src/main/twirl/gitbucket/core/settings/deploykey.scala.html
index 7f5d7de..740ec20 100644
--- a/src/main/twirl/gitbucket/core/settings/deploykey.scala.html
+++ b/src/main/twirl/gitbucket/core/settings/deploykey.scala.html
@@ -15,6 +15,9 @@
}
@key.title (@SshUtil.fingerPrint(key.publicKey).getOrElse("Key is invalid."))
+ @if(key.allowWrite){
+
+ }
Delete
}
@@ -31,7 +34,12 @@
+