forked from Normation/rudder
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
201 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
...ces/rudder/rudder-rest/src/main/scala/com/normation/rudder/rest/lift/SecretVaultApi.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
************************************************************************************* | ||
* Copyright 2021 Normation SAS | ||
************************************************************************************* | ||
* | ||
* This file is part of Rudder. | ||
* | ||
* Rudder is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* In accordance with the terms of section 7 (7. Additional Terms.) of | ||
* the GNU General Public License version 3, the copyright holders add | ||
* the following Additional permissions: | ||
* Notwithstanding to the terms of section 5 (5. Conveying Modified Source | ||
* Versions) and 6 (6. Conveying Non-Source Forms.) of the GNU General | ||
* Public License version 3, when you create a Related Module, this | ||
* Related Module is not considered as a part of the work and may be | ||
* distributed under the license agreement of your choice. | ||
* A "Related Module" means a set of sources files including their | ||
* documentation that, without modification of the Source Code, enables | ||
* supplementary functions or services in addition to those offered by | ||
* the Software. | ||
* | ||
* Rudder is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Rudder. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
************************************************************************************* | ||
*/ | ||
package com.normation.rudder.rest.lift | ||
|
||
import com.normation.rudder.rest.RestExtractorService | ||
import com.normation.rudder.web.services.SecretVaultService | ||
import com.normation.rudder.rest.RestExtractorService | ||
import com.normation.rudder.rest.{SecretVaultApi => API} | ||
import com.normation.rudder.rest.ApiPath | ||
import com.normation.rudder.rest.ApiVersion | ||
import com.normation.rudder.rest.AuthzToken | ||
import com.normation.rudder.rest.EndpointSchema0 | ||
import com.normation.rudder.rest.RestDataSerializer | ||
import com.normation.rudder.rest.RestExtractorService | ||
import com.normation.rudder.rest.RestUtils | ||
import com.normation.rudder.rest.RestUtils.getActor | ||
import com.normation.rudder.rest.RestUtils.toJsonError | ||
import com.normation.rudder.rest.RestUtils.toJsonResponse | ||
import com.normation.rudder.rest.SecretVaultApi.AddSecret | ||
import com.normation.rudder.rest.SecretVaultApi.DeleteSecret | ||
import com.normation.rudder.rest.SecretVaultApi.UpdateSecret | ||
import com.normation.rudder.rest.data._ | ||
import net.liftweb.common._ | ||
import net.liftweb.http.JsonResponse | ||
import net.liftweb.http.LiftResponse | ||
import net.liftweb.http.Req | ||
import net.liftweb.json.JArray | ||
import net.liftweb.json.JsonAST.JValue | ||
import net.liftweb.json.JsonDSL._ | ||
class SecretVaultApi( | ||
restExtractorService : RestExtractorService | ||
, secretVaultService : SecretVaultService | ||
) extends LiftApiModuleProvider[API] { | ||
|
||
import RestUtils._ | ||
|
||
def schemas = API | ||
|
||
def getLiftEndpoints(): List[LiftApiModule] = { | ||
API.endpoints.map( | ||
e => e match { | ||
case API.GetSecrets => GetSecrets | ||
case API.AddSecret => AddSecret | ||
case API.UpdateSecret => UpdateSecret | ||
case API.DeleteSecret => DeleteSecret | ||
|
||
} | ||
) | ||
} | ||
|
||
object GetSecrets extends LiftApiModule0 { | ||
val schema = API.GetSecrets | ||
val restExtractor = restExtractorService | ||
|
||
def process0(version: ApiVersion, path: ApiPath, req: Req, params: DefaultParams, authzToken: AuthzToken): LiftResponse = { | ||
JsonResponse("get secret") | ||
} | ||
} | ||
|
||
object AddSecret extends LiftApiModule { | ||
val schema = API.AddSecret | ||
val restExtractor = restExtractorService | ||
|
||
def process(version: ApiVersion, path: ApiPath, id: String, req: Req, params: DefaultParams, authzToken: AuthzToken): LiftResponse = { | ||
JsonResponse("add secret") | ||
} | ||
} | ||
|
||
|
||
object DeleteSecret extends LiftApiModule { | ||
val schema = API.AddSecret | ||
val restExtractor = restExtractorService | ||
|
||
def process(version: ApiVersion, path: ApiPath, id: String, req: Req, params: DefaultParams, authzToken: AuthzToken): LiftResponse = { | ||
JsonResponse("delete secret") | ||
} | ||
} | ||
|
||
object UpdateSecret extends LiftApiModule { | ||
val schema = API.AddSecret | ||
val restExtractor = restExtractorService | ||
|
||
def process(version: ApiVersion, path: ApiPath, id: String, req: Req, params: DefaultParams, authzToken: AuthzToken): LiftResponse = { | ||
JsonResponse("delete secret") | ||
} | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...der/rudder-rest/src/main/scala/com/normation/rudder/web/services/SecretVaultService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.normation.rudder.web.services | ||
|
||
import com.normation.errors.IOResult | ||
|
||
import java.nio.file.Path | ||
|
||
// todo reuse RudderEngineProperty ? | ||
case class SecretVaultEntry(val name: String, val value: String, val engine: String) | ||
|
||
class SecretVaultService( | ||
db: Path | ||
) { | ||
|
||
def getSecrets: IOResult[List[SecretVaultService]] = { | ||
for { | ||
|
||
} yield { | ||
|
||
} | ||
} | ||
|
||
def addSecret(secret: SecretVaultEntry): IOResult[Unit] = { | ||
for { | ||
|
||
} yield { | ||
|
||
} | ||
} | ||
|
||
def deleteSecret(secret: SecretVaultEntry): IOResult[Unit] = { | ||
for { | ||
|
||
} yield { | ||
|
||
} | ||
} | ||
|
||
def updateSecret(secret: SecretVaultEntry): IOResult[Unit] = { | ||
for { | ||
|
||
} yield { | ||
|
||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters