qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject qpid-dispatch git commit: DISPATCH-1111: take auth id from nested map entry
Date Fri, 31 Aug 2018 18:32:23 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 6e03ab8a5 -> d21597716


DISPATCH-1111: take auth id from nested map entry


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/d2159771
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/d2159771
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/d2159771

Branch: refs/heads/master
Commit: d2159771650adf8d67364009a0b53ceef62d5e71
Parents: 6e03ab8
Author: Gordon Sim <gsim@redhat.com>
Authored: Fri Aug 31 15:16:32 2018 +0100
Committer: Gordon Sim <gsim@redhat.com>
Committed: Fri Aug 31 15:16:41 2018 +0100

----------------------------------------------------------------------
 src/remote_sasl.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d2159771/src/remote_sasl.c
----------------------------------------------------------------------
diff --git a/src/remote_sasl.c b/src/remote_sasl.c
index 2fb2bcb..636d227 100644
--- a/src/remote_sasl.c
+++ b/src/remote_sasl.c
@@ -286,6 +286,7 @@ static void remote_sasl_prepare(pn_transport_t *transport)
             switch (impl->outcome) {
             case PN_SASL_OK:
                 set_policy_settings(impl->upstream, &impl->permissions);
+                qd_log(auth_service_log, QD_LOG_INFO, "authenticated as % ", impl->username);
                 pnx_sasl_succeed_authentication(transport, impl->username);
                 break;
             default:
@@ -567,18 +568,18 @@ static void* parse_properties(pn_data_t* data, permission_handler handler,
void*
     return context;
 }
 
-static pn_bytes_t extract_authenticated_identity(pn_data_t* data)
+static pn_data_t* extract_map_entry(pn_data_t* data, const char* name)
 {
-    pn_bytes_t result = pn_bytes_null;
+    pn_data_t* result = 0;
     size_t count = pn_data_get_map(data);
     pn_data_enter(data);
-    for (size_t i = 0; !result.size && i < count/2; i++) {
+    for (size_t i = 0; !result && i < count/2; i++) {
         if (pn_data_next(data)) {
-            if (pn_data_type(data) == PN_SYMBOL) {
-                pn_bytes_t key = pn_data_get_symbol(data);
-                if (key.size && key.start && strncmp(key.start, "authenticated-identity",
min(key.size, 22)) == 0) {
+            if (pn_data_type(data) == PN_SYMBOL || pn_data_type(data) == PN_STRING) {
+                pn_bytes_t key = pn_data_type(data) == PN_SYMBOL ? pn_data_get_symbol(data)
: pn_data_get_string(data);
+                if (key.size && key.start && strncmp(key.start, name, min(key.size,
strlen(name))) == 0) {
                     pn_data_next(data);
-                    result = pn_data_get_string(data);
+                    result = data;
                 } else {
                     //key didn't match, move to next pair
                     pn_data_next(data);
@@ -589,6 +590,20 @@ static pn_bytes_t extract_authenticated_identity(pn_data_t* data)
             }
         }
     }
+    return result;
+}
+
+static pn_bytes_t extract_authenticated_identity(pn_data_t* data)
+{
+    pn_bytes_t result = pn_bytes_null;
+    pn_data_t* authid = extract_map_entry(data, "authenticated-identity");
+    if (authid) {
+        pn_data_t* id = extract_map_entry(authid, "sub");
+        if (id) {
+            result = pn_data_get_string(id);
+        }
+        pn_data_exit(data);
+    }
     pn_data_exit(data);
     pn_data_rewind(data);
     pn_data_next(data);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message