Skip to content

Commit

Permalink
Merge pull request #468 from ARGOeu/devel
Browse files Browse the repository at this point in the history
Version 1.6.0
  • Loading branch information
themiszamani authored Dec 7, 2023
2 parents 462564e + 5ada7c5 commit 6d01062
Show file tree
Hide file tree
Showing 51 changed files with 6,351 additions and 1,805 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ resides in two possible locations:
- `auth_option` - (`key`|`header`|`both`), where should the service look for the access token.
- `proxy_hostname` - The FQDN of any proxy or load balancer that might serve request in place of the AMS

#### Run the tests

Inside the project's root directory issue the command:

```bash
go test ./...
```

For the db store integration test suite,
you can issue the command:
```bash
go test ./... -tags integration
```

#### Build & Run the service

In order to build the service, inside the AMS repo issue the command:
Expand Down
4 changes: 3 additions & 1 deletion argo-messaging.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Name: argo-messaging
Summary: ARGO Messaging API for broker network
Version: 1.5.0
Version: 1.6.0
Release: 1%{?dist}
License: ASL 2.0
Buildroot: %{_tmppath}/%{name}-buildroot
Expand Down Expand Up @@ -63,6 +63,8 @@ go clean
%attr(0644,root,root) /usr/lib/systemd/system/argo-messaging.service

%changelog
* Thu Dec 7 2023 Agelos Tsalapatis <[email protected]> 1.6.0-1%{?dist}
- AMS release 1.6.0
* Thu May 18 2023 Agelos Tsalapatis <[email protected]> 1.5.0-1%{?dist}
- AMS release 1.5.0
* Mon Oct 10 2022 Agelos Tsalapatis <[email protected]> 1.4.0-1%{?dist}
Expand Down
25 changes: 13 additions & 12 deletions auth/acl.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package auth

import (
"context"
"encoding/json"
"errors"

Expand Down Expand Up @@ -32,55 +33,55 @@ func GetACLFromJSON(input []byte) (ACL, error) {
}

// ModACL is called to modify an acl
func ModACL(projectUUID string, resourceType string, resourceName string, acl []string, store stores.Store) error {
func ModACL(ctx context.Context, projectUUID string, resourceType string, resourceName string, acl []string, store stores.Store) error {
// Transform user name to user uuid

userUUIDs := []string{}
for _, username := range acl {
userUUID := GetUUIDByName(username, store)
userUUID := GetUUIDByName(ctx, username, store)
userUUIDs = append(userUUIDs, userUUID)
}

return store.ModACL(projectUUID, resourceType, resourceName, userUUIDs)
return store.ModACL(ctx, projectUUID, resourceType, resourceName, userUUIDs)
}

// AppendToACL is used to append unique users to a topic's or sub's ACL
func AppendToACL(projectUUID string, resourceType string, resourceName string, acl []string, store stores.Store) error {
func AppendToACL(ctx context.Context, projectUUID string, resourceType string, resourceName string, acl []string, store stores.Store) error {

// Transform user name to user uuid
userUUIDs := []string{}
for _, username := range acl {
userUUID := GetUUIDByName(username, store)
userUUID := GetUUIDByName(ctx, username, store)
userUUIDs = append(userUUIDs, userUUID)
}

return store.AppendToACL(projectUUID, resourceType, resourceName, userUUIDs)
return store.AppendToACL(ctx, projectUUID, resourceType, resourceName, userUUIDs)
}

// AppendToACL is used to remove users from a topic's or sub's acl
func RemoveFromACL(projectUUID string, resourceType string, resourceName string, acl []string, store stores.Store) error {
func RemoveFromACL(ctx context.Context, projectUUID string, resourceType string, resourceName string, acl []string, store stores.Store) error {

// Transform user name to user uuid
userUUIDs := []string{}
for _, username := range acl {
userUUID := GetUUIDByName(username, store)
userUUID := GetUUIDByName(ctx, username, store)
userUUIDs = append(userUUIDs, userUUID)
}

return store.RemoveFromACL(projectUUID, resourceType, resourceName, userUUIDs)
return store.RemoveFromACL(ctx, projectUUID, resourceType, resourceName, userUUIDs)
}

// GetACL returns an authorized list of user for the resource (topic or subscription)
func GetACL(projectUUID string, resourceType string, resourceName string, store stores.Store) (ACL, error) {
func GetACL(ctx context.Context, projectUUID string, resourceType string, resourceName string, store stores.Store) (ACL, error) {
result := ACL{}
acl, err := store.QueryACL(projectUUID, resourceType, resourceName)
acl, err := store.QueryACL(ctx, projectUUID, resourceType, resourceName)
if err != nil {
return result, err
}
for _, item := range acl.ACL {

// Get Username from user uuid
username := GetNameByUUID(item, store)
username := GetNameByUUID(ctx, item, store)
// if username is empty, meaning that the user with this id probably doesn't exists
// skip it and don't pollute the acl with empty ""
if username == "" {
Expand Down
225 changes: 114 additions & 111 deletions auth/auth_test.go

Large diffs are not rendered by default.

Loading

0 comments on commit 6d01062

Please sign in to comment.