Hi guys, how can i give public access permissions to one of my pages. I mean, i have this pages/folders:
Page 4 -> Form panel as "@Serenity.Decorators.panel()"
I tried removing my entity4 row ReadPermissionAttribute. But i got this error:
"System.ArgumentOutOfRangeException: ServiceAuthorize attribute is created with source type of Entity4Row, but it has no ReadPermissionAttribute attribute(s)".
Then i tried '[ReadPermission("")]', but public still cant read data from my entity.
Any help is apreciated. Thanks in advance! :wink:
ReadPermission("*") means users including unauthenticated ones.
Hi @volkanceylan i made this changes on my Entity4Row:
[ReadPermission("*")]
[ModifyPermission("*")]
My Entity4Page has _[PageAuthorize(typeof(Entities.Entity4Row))]_
My Entity4Endpoint is:
using MyRow = Entities.Entity4Row;
[ConnectionKey(typeof(MyRow)), ServiceAuthorize(typeof(MyRow))]
But now when i try to place this URL on my browser:
http://[myIP]:[port]/Project/Model/Entity4/IdEntity4
Im linked to my LogIn page:
http://[myIP]:[port]/Project/Account/Login?ReturnUrl=%2fProject%2fModel%2fEntity4%2IdEntity4
What am I doing wrong? Thanks again sir!
So remove authorize from all
Ok @volkanceylan now i got this error:
Authorization.NotLoggedIn
Then i set my Entity4Endpoint from this:
[ConnectionKey(typeof(MyRow)), ServiceAuthorize(typeof(MyRow))]
To this:
[ConnectionKey(typeof(MyRow))]
And finally i can access to my Entity4 Form Panel as public user. But if i try to insert a new record or modify an existent Entity4Id i obtain this error again:
Authorization.NotLoggedIn
So I tried to change my Row for the second time like this:
[ModifyPermission("*")]
[UpdatePermission("*")]
[InsertPermission("*")]
[ReadPermission("*")]
[DeletePermission("*")]
But im still getting this error: Authorization.NotLoggedIn
The app check my Application_AuthenticateRequest and then in AuthorizationService it returns false here:
public bool IsLoggedIn
{
get { return !string.IsNullOrEmpty(Username); }
}
What should i do now. I really appreciate your help and knowledge. Many thanks!
If you intentionally want to make public. You can safely remove these
[ModifyPermission("*")]
[UpdatePermission("*")]
[InsertPermission("*")]
[ReadPermission("*")]
[DeletePermission("*")]
Thanks for your answer @dfaruque . I removed these lines:
//[ModifyPermission("*")]
//[UpdatePermission("*")]
//[InsertPermission("*")]
//[ReadPermission("*")]
//[DeletePermission("*")]
Then i received this error:
_ServiceAuthorize attribute is created with source type of Entity4Row, but it has no InsertPermissionAttribute OR ModifyPermissionAttribute OR ReadPermissionAttribute attribute(s)_
So i kept this line:
[ReadPermission("*")]
My Entity4 Form Panel its ok again, and i can read any Entity4Id used at the end of my URL (...Entity4/Id). But if i try to modify any content i still receive this error:
{Error: {Code: "NotLoggedIn", Message: "_Authorization.NotLoggedIn_"}}
I'm trying to modify these Entity4Id data as public. As any visitor, not like user logged into my app.
Thanks again!
Remove ServiceAuthorize
@alanlopcu I think you can add a tutorial about public pages and endpoints into the wiki.
After removing ServiceAuthorize attribute from class, I have removed Authorize attribute from create, update, delete method too to work done.
Most helpful comment
Remove ServiceAuthorize