Skip to content

Commit

Permalink
Remove all references to OPCUA
Browse files Browse the repository at this point in the history
  • Loading branch information
Freezor committed Jun 7, 2024
1 parent 7b3fee7 commit 375e997
Show file tree
Hide file tree
Showing 33 changed files with 22 additions and 13,098 deletions.
4 changes: 2 additions & 2 deletions src/AasCore.Aas3_0/types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8774,7 +8774,7 @@ public interface IBasicEventElement : IEventElement
/// the proprietary specification for the message broker.
/// </summary>
/// <remarks>
/// For different message infrastructure, e.g., OPC UA or MQTT or AMQP, this
/// For different message infrastructure, e.g., MQTT or AMQP, this
/// proprietary specification could be standardized by having respective Submodels.
/// </remarks>
public IReference? MessageBroker { get; set; }
Expand Down Expand Up @@ -8962,7 +8962,7 @@ public class BasicEventElement : IBasicEventElement
/// the proprietary specification for the message broker.
/// </summary>
/// <remarks>
/// For different message infrastructure, e.g., OPC UA or MQTT or AMQP, this
/// For different message infrastructure, e.g., MQTT or AMQP, this
/// proprietary specification could be standardized by having respective Submodels.
/// </remarks>
public IReference? MessageBroker { get; set; }
Expand Down
48 changes: 0 additions & 48 deletions src/AasSecurity/AasSecurityAuthenticationHandler.cs

This file was deleted.

8 changes: 0 additions & 8 deletions src/AasSecurity/AasSecurityAuthenticationOptions.cs

This file was deleted.

178 changes: 0 additions & 178 deletions src/AasSecurity/AasSecurityAuthorizationHandler.cs

This file was deleted.

3 changes: 0 additions & 3 deletions src/AasSecurity/ISecurityService.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using AasSecurity.Models;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;

namespace AasSecurity
{
public interface ISecurityService
{
AuthenticationTicket AuthenticateRequest(HttpContext context, string route, string httpOperation, string authenticationSchemeName = null);
bool AuthorizeRequest(string accessRole, string httpRoute, AccessRights neededRights, out string error, out bool withAllow, out string getPolicy, string objPath = null, string aasResourceType = null,
IClass aasResource = null, string policy = null);

Expand Down
48 changes: 0 additions & 48 deletions src/AasSecurity/SecurityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,20 @@
using AasxServerStandardBib.Logging;
using Extensions;
using Jose;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using System.Collections.Specialized;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Web;

namespace AasSecurity
{
public class SecurityService : ISecurityService
{
private static ILogger _logger = ApplicationLogging.CreateLogger("SecurityService");

public AuthenticationTicket AuthenticateRequest(HttpContext context, string route, string httpOperation, string authenticationSchemeName)
{
if (!GlobalSecurityVariables.WithAuthentication)
{
return null;
}

//Retrieve security related query strings from the request
NameValueCollection queries = HttpUtility.ParseQueryString(context.Request.QueryString.ToString());

//Retrieve headers from the request
NameValueCollection headers = new NameValueCollection();
foreach (var header in context.Request.Headers)
{
headers.Add(header.Key, header.Value.FirstOrDefault());
if (header.Key == "FORCE-POLICY")
{
Program.withPolicy = !(header.Value.FirstOrDefault() == "OFF");
_logger.LogDebug("FORCE-POLICY " + header.Value.FirstOrDefault());
}
}

var accessRole = GetAccessRole(queries, headers, out string policy, out string policyRequestedResource);
if (accessRole == null)
{
_logger.LogDebug($"Access Role found null. Hence setting the access role as isNotAuthenticated.");
accessRole = "isNotAuthenticated";
}

_logger.LogInformation($"Access role in authentication: {accessRole}, policy: {policy}, policyRequestedResource: {policyRequestedResource}");
var aasSecurityContext = new AasSecurityContext(accessRole, route, httpOperation);
//Create claims
var claims = new List<Claim>
{
new Claim(ClaimTypes.Role, aasSecurityContext.AccessRole),
new Claim("NeededRights", aasSecurityContext.NeededRights.ToString()),
new Claim("Policy", policy)
};

var identity = new ClaimsIdentity(claims, authenticationSchemeName);
var principal = new System.Security.Principal.GenericPrincipal(identity, null);
return new AuthenticationTicket(principal, authenticationSchemeName);
}

private string? GetAccessRole(NameValueCollection queries, NameValueCollection headers, out string policy, out string policyRequestedResource)
{
_logger.LogDebug("Getting the access rights.");
Expand Down
2 changes: 1 addition & 1 deletion src/AasxCsharpLibrary/IAasxOnlineConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
namespace AasxIntegrationBase
{
/// <summary>
/// This interface describes a connection for a server resource of AASX contents, such as OPC UA or REST
/// This interface describes a connection for a server resource of AASX contents, such as REST
/// </summary>
public interface IAasxOnlineConnection
{
Expand Down
6 changes: 1 addition & 5 deletions src/AasxServerAspNetCore/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public void ConfigureServices(IServiceCollection services)

services.AddControllers();
services.AddLazyResolution();
services.AddSingleton<IAuthorizationHandler, AasSecurityAuthorizationHandler>();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddSingleton<IRegistryInitializerService, RegistryInitializerService>();
services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>));
Expand Down Expand Up @@ -156,10 +155,7 @@ public void ConfigureServices(IServiceCollection services)

c.OperationFilter<IO.Swagger.Filters.GeneratePathParamsValidationFilter>();
});


services.AddAuthentication("AasSecurityAuth")
.AddScheme<AasSecurityAuthenticationOptions, AasSecurityAuthenticationHandler>("AasSecurityAuth", null);

services.AddAuthorization(c =>
{
c.AddPolicy("SecurityPolicy", policy =>
Expand Down
1 change: 0 additions & 1 deletion src/AasxServerBlazor/Configuration/DependencyRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public static void Register(IServiceCollection services)
services.AddSingleton<CredentialService>();

services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>));
services.AddSingleton<IAuthorizationHandler, AasSecurityAuthorizationHandler>();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddSingleton<IRegistryInitializerService, RegistryInitializerService>();
services.AddTransient<IAasDescriptorPaginationService, AasDescriptorPaginationService>();
Expand Down
3 changes: 0 additions & 3 deletions src/AasxServerBlazor/Configuration/ServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ public static void AddFrameworkServices(IServiceCollection services)
AddMvc(services);
AddSwaggerGen(services);

services.AddAuthentication(AuthenticationScheme)
.AddScheme<AasSecurityAuthenticationOptions, AasSecurityAuthenticationHandler>(AuthenticationScheme, null);

AddAuthorization(services);
}

Expand Down
Loading

0 comments on commit 375e997

Please sign in to comment.