Creating a custom Authenticator #30
Replies: 5 comments
-
The issue stems from the use of the non-public AuthUserList_createOrCheck function. It cannot be used in the way you're attempting, and this misuse leads to a crash inside AuthenticatedUser_constructor. We recommend implementing your custom token-based authenticator in Lua instead. The Barracuda App Server provides all the required features for token authentication in Lua, and it's the supported approach for custom authentication logic. You can find working examples here: https://realtimelogic.com/ba/doc/en/authentication.html#example |
Beta Was this translation helpful? Give feedback.
-
Ok, thanks. Iam checking it out! |
Beta Was this translation helpful? Give feedback.
-
Hello, I checked out the tutorials, but I cant seem to find one, thats actually implementing a custom Authenticator. They are all using the ba.create.authenticator function and using one of the predefined authenticator types, for example basic or auth. I also read that these authenticators are using the c implementation. What I am trying to achieve is to create a rest api with the BAS and I cant really see how I should do this in Lua with the lua server pages, because they seem to be designed to send html back to the client, when html is often not what I want. In the c++ code I can extend my classes with HttpPage or HttpDir and overwrite the service function to implement my rest api logic. There I dont need the html. So this works fine for me. But I want to be able to create a token authentication method and maybe some other custom method in the future. So the question is either how do I create a TokenAuthenticator class in c++ (or maybe I have to do it in c and extend BAS.c?) or how do I use the lua server pages to implement a rest api (and also how do I do token authentication, because I couldnt find a custom authenticator)? Maybe I dont understand something crutial in the lua examples. Maybe there are examples and I just dont see that they do what I want? Help would be much appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Your REST API concern: while Lua directory functions and LSP are often used to generate HTML, they are not limited to HTML at all. In fact, when using directory functions or LSP, you can return JSON, XML, binary, or whatever content type you need. LSP is just a mechanism; it's up to you how you use it. The ba.create.authenticator function in Lua wraps the underlying C implementation and gives you full control over how authentication is performed, including implementing your own token-based logic. You don't need to create a "custom authenticator class" like in C++; instead, you write a handler (a Lua function or directory object) that implements your own authentication logic before executing protected routes. Examples that use custom auth: Single Sign-On, Passwordless Authentication with WebAuthn, RADIUS Authentication, OAuth 2.0 Authentication. I cannot be more specific since I do not know how you intend your custom authenticator to work. Since you're working on a commercial product and deploying on QNX, we strongly recommend reaching out to Real Time Logic to set up a support agreement. This will give you direct access to expert assistance, ensure you're following best practices, and help you avoid pitfalls |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for the additional information. I'll try it out! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Iam trying to create a custom Authenticator for Token Authentification, but I have a hard time doing so. As I understand it, I need to implement the AuthenticatorIntf and the authenticate function. Within this function I need to construct the AuthInfo Object and the AuthenticatedUser, eg TokenAuthUser. I also need to create a new HttpSession with req->getSession(TRUE). This is a point where I get a Memory fault. When using the other Authenticator everything works fine, but they require me to use username:password for example when using BasicAuthenticator.
So the question is, how do I properly implement my own custom Authenticator.
Im running this Server on a QNX7.1 platform.
With kind regards
Here is the code I have so far
Beta Was this translation helpful? Give feedback.
All reactions