* Restconf authentication callback (ca_auth) signature changed

* Not backward compatible: All uses of the ca-auth callback in restconf plugins must be changed
  * New version is: `int ca_auth(h, req, auth_type, authp, userp)`
    * where `auth_type` is the requested authentication-type (none, client-cert or user-defined)
    * `authp` is the returned authentication flag
    * `userp` is the returned associated authenticated user
    * and the return value is three-valued: -1: Error, 0: not handled, 1: OK
  * For more info see [clixon-docs/restconf](https://clixon-docs.readthedocs.io/en/latest/restconf.html)
This commit is contained in:
Olof hagsand 2021-03-07 15:34:26 +01:00
parent 699115736d
commit a8d29b1e7e
5 changed files with 69 additions and 63 deletions

View file

@ -513,7 +513,7 @@ restconf_authentication_cb(clicon_handle h,
clixon_auth_type_t auth_type;
int authenticated;
int ret;
char *username = NULL;
char *username = NULL; /* Assume malloced if set */
cxobj *xret = NULL;
cxobj *xerr;
char *anonymous = NULL;
@ -525,12 +525,13 @@ restconf_authentication_cb(clicon_handle h,
/* ret: -1 Error, 0: Ignore/not handled, 1: OK see authenticated parameter */
if ((ret = clixon_plugin_auth_all(h, req,
auth_type,
&authenticated,
&username)) < 0)
goto done;
if (ret == 1){ /* OK, tag username to handle */
if (authenticated == 1)
if (username != NULL){
authenticated = 1;
clicon_username_set(h, username);
}
}
else { /* Default behaviour */
switch (auth_type){