|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (C) 2026 the Eclipse BaSyx Authors |
| 3 | + * |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | + * a copy of this software and associated documentation files (the |
| 6 | + * "Software"), to deal in the Software without restriction, including |
| 7 | + * without limitation the rights to use, copy, modify, merge, publish, |
| 8 | + * distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | + * permit persons to whom the Software is furnished to do so, subject to |
| 10 | + * the following conditions: |
| 11 | + * |
| 12 | + * The above copyright notice and this permission notice shall be |
| 13 | + * included in all copies or substantial portions of the Software. |
| 14 | + * |
| 15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 18 | + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 19 | + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 20 | + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 21 | + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | + * |
| 23 | + * SPDX-License-Identifier: MIT |
| 24 | + ******************************************************************************/ |
| 25 | + |
| 26 | +package org.eclipse.digitaltwin.basyx.submodelrepository.feature.operation.delegation; |
| 27 | + |
| 28 | +import java.util.ArrayList; |
| 29 | +import java.util.List; |
| 30 | + |
| 31 | +import org.springframework.boot.context.properties.ConfigurationProperties; |
| 32 | + |
| 33 | +/** |
| 34 | + * Security properties for outbound operation delegation requests. |
| 35 | + */ |
| 36 | +@ConfigurationProperties(prefix = OperationDelegationSubmodelRepositoryFeature.FEATURENAME + ".security") |
| 37 | +public class OperationDelegationSecurityProperties { |
| 38 | + |
| 39 | + private boolean enabled = true; |
| 40 | + private boolean denyPrivateTargets = true; |
| 41 | + private boolean denyLinkLocalTargets = true; |
| 42 | + private boolean denyLoopbackTargets = true; |
| 43 | + private boolean denyMetadataTargets = true; |
| 44 | + private boolean denyRedirects = true; |
| 45 | + private Allowlist allowlist = new Allowlist(); |
| 46 | + |
| 47 | + public boolean isEnabled() { |
| 48 | + return enabled; |
| 49 | + } |
| 50 | + |
| 51 | + public void setEnabled(boolean enabled) { |
| 52 | + this.enabled = enabled; |
| 53 | + } |
| 54 | + |
| 55 | + public boolean isDenyPrivateTargets() { |
| 56 | + return denyPrivateTargets; |
| 57 | + } |
| 58 | + |
| 59 | + public void setDenyPrivateTargets(boolean denyPrivateTargets) { |
| 60 | + this.denyPrivateTargets = denyPrivateTargets; |
| 61 | + } |
| 62 | + |
| 63 | + public boolean isDenyLinkLocalTargets() { |
| 64 | + return denyLinkLocalTargets; |
| 65 | + } |
| 66 | + |
| 67 | + public void setDenyLinkLocalTargets(boolean denyLinkLocalTargets) { |
| 68 | + this.denyLinkLocalTargets = denyLinkLocalTargets; |
| 69 | + } |
| 70 | + |
| 71 | + public boolean isDenyLoopbackTargets() { |
| 72 | + return denyLoopbackTargets; |
| 73 | + } |
| 74 | + |
| 75 | + public void setDenyLoopbackTargets(boolean denyLoopbackTargets) { |
| 76 | + this.denyLoopbackTargets = denyLoopbackTargets; |
| 77 | + } |
| 78 | + |
| 79 | + public boolean isDenyMetadataTargets() { |
| 80 | + return denyMetadataTargets; |
| 81 | + } |
| 82 | + |
| 83 | + public void setDenyMetadataTargets(boolean denyMetadataTargets) { |
| 84 | + this.denyMetadataTargets = denyMetadataTargets; |
| 85 | + } |
| 86 | + |
| 87 | + public boolean isDenyRedirects() { |
| 88 | + return denyRedirects; |
| 89 | + } |
| 90 | + |
| 91 | + public void setDenyRedirects(boolean denyRedirects) { |
| 92 | + this.denyRedirects = denyRedirects; |
| 93 | + } |
| 94 | + |
| 95 | + public Allowlist getAllowlist() { |
| 96 | + return allowlist; |
| 97 | + } |
| 98 | + |
| 99 | + public void setAllowlist(Allowlist allowlist) { |
| 100 | + this.allowlist = allowlist; |
| 101 | + } |
| 102 | + |
| 103 | + public static class Allowlist { |
| 104 | + private List<String> hosts = new ArrayList<>(); |
| 105 | + private List<String> cidrs = new ArrayList<>(); |
| 106 | + private List<Integer> ports = new ArrayList<>(); |
| 107 | + |
| 108 | + public List<String> getHosts() { |
| 109 | + return hosts; |
| 110 | + } |
| 111 | + |
| 112 | + public void setHosts(List<String> hosts) { |
| 113 | + this.hosts = hosts; |
| 114 | + } |
| 115 | + |
| 116 | + public List<String> getCidrs() { |
| 117 | + return cidrs; |
| 118 | + } |
| 119 | + |
| 120 | + public void setCidrs(List<String> cidrs) { |
| 121 | + this.cidrs = cidrs; |
| 122 | + } |
| 123 | + |
| 124 | + public List<Integer> getPorts() { |
| 125 | + return ports; |
| 126 | + } |
| 127 | + |
| 128 | + public void setPorts(List<Integer> ports) { |
| 129 | + this.ports = ports; |
| 130 | + } |
| 131 | + } |
| 132 | +} |
0 commit comments