2017-08-17 98 views
0

我有環迴應用程序,我有型號名稱照片。我在我的本地主機上工作,嘗試發佈在照片模式,它工作正常。但是,當我構建它並嘗試在在線服務器上POST時,我得到授權所需的錯誤。環回POST方法不起作用

我的ACL是這樣的:

"acls": [ 
{ 
    "accessType": "*", 
    "principalType": "ROLE", 
    "principalId": "$everyone", 
    "permission": "DENY" 
}, 
{ 
    "accessType": "*", 
    "principalType": "ROLE", 
    "principalId": "admin", 
    "permission": "ALLOW" 
}, 
{ 
    "accessType": "*", 
    "principalType": "ROLE", 
    "principalId": "$owner", 
    "permission": "ALLOW" 
}, 
{ 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$everyone", 
    "permission": "ALLOW", 
    "property": "findById" 
}, 
{ 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$everyone", 
    "permission": "ALLOW", 
    "property": "__get__comments" 
}, 
{ 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$everyone", 
    "permission": "ALLOW", 
    "property": "__count__comments" 
}, 
{ 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$everyone", 
    "permission": "ALLOW", 
    "property": "__get__likes" 
}, 
{ 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$everyone", 
    "permission": "ALLOW", 
    "property": "__count__likes" 
}, 
{ 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$authenticated", 
    "permission": "ALLOW", 
    "property": "__create__comments" 
}, 
{ 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$everyone", 
    "permission": "ALLOW", 
    "property": "find" 
}, 
{ 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$authenticated", 
    "permission": "ALLOW", 
    "property": "create" 
} 
+0

我想你應該首先測試路由,而不需要任何ACL。如果有效,那麼你可以進入下一步並添加ACL。你能包括你的路線和參數嗎? –

回答

0

首先,一些清理工作:你可以在許多類似ACLSs合併成一個單一的塊:

{ 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$everyone", 
    "permission": "ALLOW", 
    "property": [ 
    "find", 
    "findById", 
    "__get__likes", 
    "__get__comments", 
    "__count__likes", 
    "__count__comments" 
    ] 
}, 

...和第二:是您登錄當試圖在您的服務器上提出請求時?檢查'授權'令牌是否正在發送,並且是否正常。相同的數據庫或從本地主機的不同數據庫?

+0

YeeHaw1234是的,我登錄,然後嘗試發佈和授權發送。這兩個數據庫都是MySQL –

+0

不幸的是我沒有一個快速的答案。我唯一的建議是更多的調試。如果您有權訪問服務器的控制檯,請使用以下命令運行環回:DEBUG = loopback:security:access-context。這將顯示安全調試信息,您可以查看確切的用戶登錄方式以及拋出AUTHORIZATION_REQUIRED錯誤的方法 – YeeHaw1234