Replies: 2 comments 16 replies
-
Oqtane uses a client/server architecture and it's REST API is designed to ensure only authorized clients have access. There is no option to bypass these security requirements, as that would expose a security vulnerability. If you want to create an external client application that adds users I would suggest you create a flow which first establishes a security context and then calls the API. You can use the standard HTTPClient or a library such as RestSharp to do this. |
Beta Was this translation helpful? Give feedback.
-
Hate to bring back an old topic, but I'm struggling with this similar problem. I need non-admin users assigned to a custom role (e.g. "Profile Editors") to be able to create/edit users and their profile properties (about 40 profile settings fields), but not be a full site administrator. My first thought was to use copies of the Users module Add/Edit/Roles screens in my own module, but then realized that the API security still wouldn't allow this to function. I'm looking for a little more guidance than just #3 above from Shaun. Seems that some granular assignment of rights via roles could benefit many orgs/users as having an all or none access via Administrator is just too restrictive. As a work-around, how could I have a regular user call the built-in user add/edit screens via impersonation with an Admin user credential? |
Beta Was this translation helpful? Give feedback.
-
Hello,
This is the case:
I would like to auto-register users after validating credentials against another authentication provider, but this is irrelevant to the problem I'm facing.
After the user successfully authenticates in the external system, I would like to create (if it doesn't already exists) new a user account in Oqtane to make it work as any regular user account. How to take care of keeping things in sync and secure is irrelevant to to the problem I'm facing.
Everything goes well until I do:
This returns
null
because (a) nobody is already logged in (this module acts as an alternate to the standard login module), and (b)AllowRegistration
is disabled in the site.In
\oqtane.framework\Oqtane.Server\Controllers\UserController.cs
, insideprivate async Task<User> CreateUser(User user)
, the first problem I'm facing is that of courseif (User.IsInRole(RoleNames.Admin))
is false because there is nobody logged in.In addition,
This means the user will not be created as verified and it will not be created at all because
AllowRegistration
is disabled.So, the question is, how can I programmatically create a new user without having to be running the site already logged in as an Admin?
Is there a way to temporarily change the security context for this to work? (For example, Sitecore allows doing something like this. i.e. run a piece of code impersonating someone else).
Said all of this, which options do I currently have to programmatically create a new user in Oqtane avoiding the limitations and security checks set in
private async Task<User> CreateUser(User user)
?Should I copy & paste the code and create my own version or is there a better way (i.e. using the Oqtane APIs as they are)?
Thanks!
** EDIT **
I understand Oqtane's server API is not the same as the DNN API, but I guess there should be a way to do this kind of things 'server side' outside the context of who si running the code?
Beta Was this translation helpful? Give feedback.
All reactions