From 51bf9d6c9e522ecc31f9068d9e5eaa0321fef587 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 20 Dec 2022 19:14:32 +0800 Subject: Develop secret api. v49 --- .../CrupestApi/CrupestApi.Commons/Secrets/ISecretService.cs | 8 ++++++++ .../CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/ISecretService.cs (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets') diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/ISecretService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/ISecretService.cs new file mode 100644 index 0000000..83025f8 --- /dev/null +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/ISecretService.cs @@ -0,0 +1,8 @@ +namespace CrupestApi.Commons.Secrets; + +public interface ISecretService +{ + void CreateTestSecret(string key, string secret); + + List GetPermissions(string secret); +} diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs index 4d9b14c..47e9583 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs @@ -1,4 +1,5 @@ using CrupestApi.Commons.Crud; +using Dapper; namespace CrupestApi.Commons.Secrets; @@ -23,6 +24,12 @@ public class SecretService : CrudService, ISecretService transaction.Commit(); } + public void CreateTestSecret(string key, string secret) + { + var connection = _dbConnection; + connection.Execute("INSERT INTO secrets (key, secret, description) VALUES (@key, @secret, @desc)", new { key, secret, desc = "Test key." }); + } + public List GetPermissions(string secret) { var list = _table.Select(_dbConnection, -- cgit v1.2.3