Access Request Configuraton Attributes in Module-Configuration
Hi everyone I wonder if I can access the configuration attributes of a request in the module configuration. I.e. in the code a configuration attribute is set like this: pair_make_config("Custom-My-Attrib", "Some value, T_OP_ADD); It would be nice if i could access this in a configuration file, so it can be expanded in a string: my_module { some_param = "foobar-%{???:Custom-My-Attrib}" } Is something like this possible? Cheers T
On Sep 9, 2020, at 3:53 PM, g4-lisz@tonarchiv.ch wrote:
I wonder if I can access the configuration attributes of a request in the module configuration.
That's mixing up two different things. The module configuration is largely static. Not always, but mostly. This is because the modules do things which don't change over time. In contrast, the request is dynamic. The attributes in the request are used while the request is alive. The attributes are then discarded when the request is finished.
I.e. in the code a configuration attribute is set like this:
pair_make_config("Custom-My-Attrib", "Some value, T_OP_ADD);
It's just an attribute. It doesn't matter if it's in the control list, request list, reply list, etc. The server doesn't care. The lists are really just logical groupings. You can reference any attribute in any list, pretty much anywhere in the server.
It would be nice if i could access this in a configuration file, so it can be expanded in a string:
my_module {
some_param = "foobar-%{???:Custom-My-Attrib}"
}
Which module? Why?
Is something like this possible?
The "detail" module does dynamic expansion of filenames. The "linelog" does something similar. They both use the "xlat" API for dynamic expansions. Perhaps you could ask a *specific* question. Right now, you're asking "Can I do stuff?". Well, yes. Perhaps. Sometimes. Ask a detailed question and you will get a detailed answer. Ask a vague question and you will get a vague answer. Sure, the server can do stuff. What kind of stuff do you want to do? Alan DeKok.
Hi Alan, thank you very much for the quick answer. You already gave me the hint i needed: "It's just an attribute. It doesn't matter if it's in the control list, request list, reply list, etc.". I adapted the rlm_rest module to my needs. Most of it's configuration parameters like URI for example are expanded when a request is handled. So this shouldn't be an issue. I use some realm to OAuth mapping. This mapping is stored in a DB. When a request is received, the mapping is read from from the DB and some OAuth parameters are added to the request configuration. Like this it can be used in different places of the request processing. I did not want to change the section xlat part of the original rlm_rest code. So it helps a lot when these OAuth parameters can also be expanded as request attributes. Cheers, T On 09.09.20 21:59, Alan DeKok wrote:
On Sep 9, 2020, at 3:53 PM, g4-lisz@tonarchiv.ch wrote:
I wonder if I can access the configuration attributes of a request in the module configuration. That's mixing up two different things.
The module configuration is largely static. Not always, but mostly. This is because the modules do things which don't change over time.
In contrast, the request is dynamic. The attributes in the request are used while the request is alive. The attributes are then discarded when the request is finished.
I.e. in the code a configuration attribute is set like this:
pair_make_config("Custom-My-Attrib", "Some value, T_OP_ADD); It's just an attribute. It doesn't matter if it's in the control list, request list, reply list, etc. The server doesn't care. The lists are really just logical groupings. You can reference any attribute in any list, pretty much anywhere in the server.
It would be nice if i could access this in a configuration file, so it can be expanded in a string:
my_module {
some_param = "foobar-%{???:Custom-My-Attrib}"
} Which module? Why?
Is something like this possible? The "detail" module does dynamic expansion of filenames. The "linelog" does something similar. They both use the "xlat" API for dynamic expansions.
Perhaps you could ask a *specific* question. Right now, you're asking "Can I do stuff?". Well, yes. Perhaps. Sometimes.
Ask a detailed question and you will get a detailed answer. Ask a vague question and you will get a vague answer.
Sure, the server can do stuff. What kind of stuff do you want to do?
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On 09.09.20 21:53, g4-lisz@tonarchiv.ch wrote:
Hi everyone
I wonder if I can access the configuration attributes of a request in the module configuration.
I.e. in the code a configuration attribute is set like this:
pair_make_config("Custom-My-Attrib", "Some value, T_OP_ADD);
It would be nice if i could access this in a configuration file, so it can be expanded in a string:
my_module {
some_param = "foobar-%{???:Custom-My-Attrib}"
}
Is something like this possible?
By the way, the solution was: some_param = "foobar-%{control:Custom-My-Attrib}" I.e. what is request->config in the API is "control" in xlat.
participants (2)
-
Alan DeKok -
g4-lisz@tonarchiv.ch