Regarding- Error facing on "Unauthorized" ​​ message: "Authentication is required"

47 views
Skip to first unread message

geethanjali alaguraj

unread,
Oct 20, 2023, 1:27:10 AM10/20/23
to DSpace Technical Support
Hi,

i have added an drop-down field called community in the new user registration page. In here it fetches the available communities from database and shown in the drop down.

Now i want to create an read permission for the user who registered for the selected community.
(example: if John is a new user who try to register through their email, In registration form John select Community1 so when he submit the for the read policy has to create for John uuid with community1 uuid)

I have try this but it shows error like :

An error occurred: Object { headers: {…}, status: 401, statusText: "OK", url: "http://localhost:8080/server/api/authz/resourcepolicies", ok: false, name: "HttpErrorResponse", message: "Http failure response for http://localhost:8080/server/api/authz/resourcepolicies: 401 OK", error: {…} } ​ error: Object { timestamp: "2023-10-18T07:01:13.751+00:00", status: 401, error: "Unauthorized", … } ​​ error: "Unauthorized" ​​ message: "Authentication is required" ​​ path: "/server/api/authz/resourcepolicies" ​​ status: 401 ​​ timestamp: "2023-10-18T07:01:13.751+00:00" ​​ <prototype>: Object { … } ​ headers: Object { normalizedNames: Map(5), lazyUpdate: null, lazyInit: null, … } ​ message: "Http failure response for http://localhost:8080/server/api/authz/resourcepolicies: 401 OK" ​ name: "HttpErrorResponse" ​ ok: false ​ status: 401 ​ statusText: "OK" ​ url: "http://localhost:8080/server/api/authz/resourcepolicies" ​

can anyone know how to resolve this error or else how can i get the admin access token

DSpace Technical Support

unread,
Oct 23, 2023, 11:44:58 AM10/23/23
to DSpace Technical Support
Hi,

That "/api/authz/resourcepolicies" endpoint is only available to accounts with Administrator permissions (and always requires authentication to access even basic information).   Normal users or anonymous users cannot use that endpoint to add new or modify existing ones policies. This is for security reasons, as allowing other users to use this endpoint would also allow them to change the permissions of any object within DSpace (as that "resourcepolicies" endpoint can be potentially used to manage every object in the system)

So, I suspect you'd need to either create a new REST endpoint or customize the backend to do what you need to do.  But, be very careful about security when creating new endpoints.  DSpace purposefully locks down endpoints to Admin-only (or applies other security protections) when it is dangerous to make them publicly callable... this is a security feature. 

Tim

geethanjali alaguraj

unread,
Oct 25, 2023, 12:49:41 AM10/25/23
to DSpace Technical Support
Hello,
Thanks for your reply.

Is that possible to create new endpoint to store that policy in resource policy table for the normal user, or
is that possible to create policy for the normal user with with admin credentials (username and password)

Or else I want to create multiple tables like 1. Administrator- has all access
2. Anonymous- has read permissions
3. group3 - only have access to read for particular community/collection etc
4.group4 - only have permission to write in particular community/collection/item etc


here for admin, anonymous we have all permissions, policies now i have added 2 fields in new user registration(front-end) 1. grouptype - here it fetches the available group from db  2. community type- here it fetches the stored community from db so when a new user register if they select group 3 in grouptype and community type it has to create an policy respect to that group and store that in resource policy table

--
All messages to this mailing list should adhere to the Code of Conduct: https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx
---
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/1b19e2d7-6233-4bcf-b269-e82fb63260bfn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages