mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-02-12 19:22:45 +00:00
global: move more config to env vars
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 =>
|
||||
|
||||
Reference in New Issue
Block a user