]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Set job-originating-user-xxx attributes using OAuth values when possible (Issue ...
authorMichael R Sweet <msweet@msweet.org>
Wed, 16 Apr 2025 16:29:03 +0000 (12:29 -0400)
committerMichael R Sweet <msweet@msweet.org>
Wed, 16 Apr 2025 16:29:03 +0000 (12:29 -0400)
scheduler/ipp.c

index 6c49fe408db5171e6f1303be374cf077be4a91fd..a4997f1fe628752677879f29dbc396501d96e6f8 100644 (file)
@@ -1524,7 +1524,14 @@ add_job(cupsd_client_t  *con,            /* I - Client connection */
   add_job_uuid(job);
   apply_printer_defaults(printer, job);
 
-  if (con->username[0])
+  if (con->realname[0])
+  {
+    cupsdSetString(&job->username, con->realname);
+
+    if (attr)
+      ippSetString(job->attrs, &attr, 0, con->realname);
+  }
+  else if (con->username[0])
   {
     cupsdSetString(&job->username, con->username);
 
@@ -1541,14 +1548,20 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
     cupsdSetString(&job->username, "anonymous");
 
   if (!attr)
-    ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME,
-                 "job-originating-user-name", NULL, job->username);
+  {
+    ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-originating-user-name", NULL, job->username);
+  }
   else
   {
     ippSetGroupTag(job->attrs, &attr, IPP_TAG_JOB);
     ippSetName(job->attrs, &attr, "job-originating-user-name");
   }
 
+  if (con->email[0])
+    ippAddStringf(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-originating-user-uri", NULL, "mailto:", con->email);
+  else
+    ippAddStringf(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-originating-user-uri", NULL, "urn:sub:", con->username);
+
   if (con->username[0] || auth_info)
   {
     save_auth_info(con, job, auth_info);
@@ -7827,7 +7840,9 @@ get_username(cupsd_client_t *con) /* I - Connection */
   ipp_attribute_t      *attr;          /* Attribute */
 
 
-  if (con->username[0])
+  if (con->realname[0])
+    return (con->realname);
+  else if (con->username[0])
     return (con->username);
   else if ((attr = ippFindAttribute(con->request, "requesting-user-name",
                                     IPP_TAG_NAME)) != NULL)