Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ object CoSecAttributesExtractor : AttributesExtractor<SecurityContext, Authorize
private val USER_ID_ATTRIBUTE_KEY = stringKey("user.id")
private val USER_ROLES_ATTRIBUTE_KEY = stringArrayKey("user.roles")
private const val COSEC_TENANT_ID_KEY = CoSec.COSEC_PREFIX + "tenant_id"
private const val COSEC_SPACE_ID_KEY = CoSec.COSEC_PREFIX + "space_id"
private const val COSEC_APP_ID_KEY = CoSec.COSEC_PREFIX + "app_id"
private const val COSEC_REQUEST_ID_KEY = CoSec.COSEC_PREFIX + "request_id"
private val COSEC_TENANT_ID_ATTRIBUTE_KEY = stringKey(COSEC_TENANT_ID_KEY)
private val COSEC_SPACE_ID_ATTRIBUTE_KEY = stringKey(COSEC_SPACE_ID_KEY)
private val COSEC_APP_ID_ATTRIBUTE_KEY = stringKey(COSEC_APP_ID_KEY)
private val COSEC_DEVICE_ID_ATTRIBUTE_KEY = stringKey("device.id")
private val COSEC_REQUEST_ID_ATTRIBUTE_KEY = stringKey(COSEC_REQUEST_ID_KEY)
Expand Down Expand Up @@ -112,6 +114,10 @@ object CoSecAttributesExtractor : AttributesExtractor<SecurityContext, Authorize
if (requestId.isNotBlank()) {
attributes.put(COSEC_REQUEST_ID_ATTRIBUTE_KEY, requestId)
}
val spaceId = cosecRequest.spaceId
if (spaceId.isNotBlank()) {
attributes.put(COSEC_SPACE_ID_ATTRIBUTE_KEY, spaceId)
}
}
val securityContext = request
val principal = securityContext.principal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class CoSecAttributesExtractorTest {
every { appId } returns "appId"
every { deviceId } returns "deviceId"
every { requestId } returns "requestId"
every { spaceId } returns "spaceId"
}
val verifyContext = mockk<PolicyVerifyContext> {
every { policy.id } returns "policyId"
Expand Down Expand Up @@ -86,6 +87,7 @@ class CoSecAttributesExtractorTest {
every { appId } returns "appId"
every { deviceId } returns "deviceId"
every { requestId } returns "requestId"
every { spaceId } returns "spaceId"
}
val verifyContext = mockk<RoleVerifyContext> {
every { roleId } returns "roleId"
Expand Down Expand Up @@ -113,6 +115,7 @@ class CoSecAttributesExtractorTest {
every { appId } returns ""
every { deviceId } returns ""
every { requestId } returns ""
every { spaceId } returns ""
}
val securityContext = SimpleSecurityContext.anonymous()
securityContext.setRequest(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class TracingAuthorizationTest {
every { appId } returns "appId"
every { deviceId } returns "deviceId"
every { requestId } returns "requestId"
every { spaceId } returns "spaceId"
}
val verifyContext = mockk<RoleVerifyContext> {
every { roleId } returns "roleId"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# limitations under the License.
#
group=me.ahoo.cosec
version=3.3.0
version=3.3.1
description=RBAC-based And Policy-based Multi-Tenant Reactive Security Framework.
website=https://github.com/Ahoo-Wang/CoSec
issues=https://github.com/Ahoo-Wang/CoSec/issues
Expand Down
Loading