Skip to content

Commit

Permalink
Merge pull request #187 from OpenBracketsCH/development
Browse files Browse the repository at this point in the history
Change auth to oAuth2
  • Loading branch information
elektrolytmangel authored May 28, 2024
2 parents d21e867 + 492881f commit e040a45
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions backend/Configuration/ServiceConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class ServiceConfiguration

public string OsmUserName { get; set; }

public string OsmUserPassword { get; set; }
public string OsmApiToken { get; set; }

public string OverpassApiUrl { get; set; }

Expand All @@ -26,7 +26,7 @@ public static ServiceConfiguration Initialize(IConfigurationRoot configuration)
{
OsmApiUrl = configuration.GetConnectionStringOrSetting("OSM_API_URL"),
OsmUserName = configuration.GetConnectionStringOrSetting("OSM_USER_NAME"),
OsmUserPassword = configuration.GetConnectionStringOrSetting("OSM_USER_PASSWORD"),
OsmApiToken = configuration.GetConnectionStringOrSetting("OSM_API_TOKEN"),
OverpassApiUrl = configuration.GetConnectionStringOrSetting("OVERPASS_URL"),
BlobStoragaConnectionString = configuration.GetConnectionStringOrSetting("AzureWebJobsStorage"),
BlobStorageContainerName = configuration.GetConnectionStringOrSetting("BLOB_STORAGE_CONTAINER_NAME"),
Expand Down
8 changes: 4 additions & 4 deletions backend/DefibrillatorFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ public async Task<IActionResult> Create(
try
{
var username = _config.OsmUserName;
var password = _config.OsmUserPassword;
var osmApiToken = _config.OsmApiToken;
var osmApiUrl = _config.OsmApiUrl;

if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(osmApiUrl))
if (string.IsNullOrEmpty(osmApiToken) || string.IsNullOrEmpty(osmApiUrl))
{
log.LogWarning("No valid configuration available for eighter username, password or osmApiUrl");
log.LogWarning("No valid configuration available for eighter osmApitoken or osmApiUrl");
return new InternalServerErrorResult();
}

Expand All @@ -104,7 +104,7 @@ public async Task<IActionResult> Create(
var newNode = CreateNode(defibrillatorObj.Value);
var clientFactory = new ClientsFactory(log, new HttpClient(), osmApiUrl);

var authClient = clientFactory.CreateBasicAuthClient(username, password);
var authClient = clientFactory.CreateOAuth2Client(osmApiToken);
var changeSetTags = new TagsCollection() { new Tag("created_by", username), new Tag("comment", "Create new AED.") };
var changeSetId = await authClient.CreateChangeset(changeSetTags);

Expand Down
6 changes: 3 additions & 3 deletions backend/DefibrillatorFunctionV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public async Task<IActionResult> Create(
try
{
var username = _config.OsmUserName;
var password = _config.OsmUserPassword;
var osmApiToken = _config.OsmApiToken;
var osmApiUrl = _config.OsmApiUrl;

if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(osmApiUrl))
if (string.IsNullOrEmpty(osmApiToken) || string.IsNullOrEmpty(osmApiUrl))
{
log.LogWarning("No valid configuration available for eighter username, password or osmApiUrl");
return new InternalServerErrorResult();
Expand All @@ -104,7 +104,7 @@ public async Task<IActionResult> Create(
var newNode = CreateNode(defibrillatorObj.Value);
var clientFactory = new ClientsFactory(log, new HttpClient(), osmApiUrl);

var authClient = clientFactory.CreateBasicAuthClient(username, password);
var authClient = clientFactory.CreateOAuth2Client(osmApiToken);
var changeSetTags = new TagsCollection() { new Tag("created_by", username), new Tag("comment", "Create new AED.") };
var changeSetId = await authClient.CreateChangeset(changeSetTags);

Expand Down

0 comments on commit e040a45

Please sign in to comment.