global: move more config to env vars

This commit is contained in:
Abdullah Atta
2022-12-29 11:18:29 +05:00
parent 9463d484a4
commit 3f89ebc214
24 changed files with 101 additions and 167 deletions

View File

@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using Notesnook.API.Interfaces;
using Notesnook.API.Models;
using Notesnook.API.Repositories;
using Streetwriters.Common.Models;
using Streetwriters.Data.Repositories;
namespace Notesnook.API.Accessors

View File

@@ -17,7 +17,6 @@ You should have received a copy of the Affero GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;

View File

@@ -24,7 +24,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization.Policy;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.SignalR;
namespace Notesnook.API.Authorization
{

View File

@@ -24,7 +24,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Notesnook.API.Models;
using Streetwriters.Common.Models;
using Streetwriters.Data.Interfaces;
using Streetwriters.Data.Repositories;

View File

@@ -19,14 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Amazon.S3;
using Amazon.Runtime;
using Amazon.S3.Model;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Security.Claims;
using System.Net.Http;
using System.Linq;
using Notesnook.API.Interfaces;
using System;

View File

@@ -24,8 +24,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization.Policy;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Notesnook.API.Authorization;
namespace Notesnook.API.Extensions
{

View File

@@ -1,6 +1,4 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using Streetwriters.Common.Interfaces;
using Streetwriters.Common.Models;
namespace Notesnook.API.Models.Responses

View File

@@ -1,6 +1,4 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using Notesnook.API.Interfaces;
using Streetwriters.Common.Interfaces;
using Streetwriters.Common.Models;

View File

@@ -17,10 +17,6 @@ You should have received a copy of the Affero GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.Mvc;
namespace Notesnook.API.Models
{
public class S3Options

View File

@@ -39,15 +39,16 @@ namespace Notesnook.API.Services
private AmazonS3Client S3Client { get; }
private HttpClient httpClient = new HttpClient();
public S3Service(IOptions<S3Options> s3Options)
public S3Service()
{
var config = new AmazonS3Config
{
#if DEBUG
ServiceURL = Servers.S3Server.ToString(),
#else
ServiceURL = s3Options.Value.ServiceUrl,
AuthenticationRegion = s3Options.Value.Region,
ServiceURL = Constants.S3_SERVICE_URL,
AuthenticationRegion = Constants.S3_REGION,
#endif
ForcePathStyle = true,
SignatureMethod = SigningAlgorithm.HmacSHA256,
@@ -56,7 +57,7 @@ namespace Notesnook.API.Services
#if DEBUG
S3Client = new AmazonS3Client("S3RVER", "S3RVER", config);
#else
S3Client = new AmazonS3Client(s3Options.Value.AccessKeyId, s3Options.Value.SecretAccessKey, config);
S3Client = new AmazonS3Client(Constants.S3_ACCESS_KEY_ID, Constants.S3_ACCESS_KEY, config);
#endif
AWSConfigsS3.UseSignatureVersion4 = true;
}

View File

@@ -127,7 +127,7 @@ namespace Notesnook.API
.AddOAuth2Introspection("introspection", options =>
{
options.Authority = Servers.IdentityServer.ToString();
options.ClientSecret = Environment.GetEnvironmentVariable("NOTESNOOK_API_SECRET");
options.ClientSecret = Constants.NOTESNOOK_API_SECRET;
options.ClientId = "notesnook";
options.DiscoveryPolicy.RequireHttps = false;
options.TokenRetriever = new Func<HttpRequest, string>(req =>