2016-03-18 82 views
1

我一直在試圖理解在過去幾個小時,我爲什麼不能驗證迴環驗證錯誤

後訪問我的任何型號的說我有在它下面的一個模型my_model的JSON文件

"acls": [ 
    { 
     "accessType": "*", 
     "property" : "*", 
     "principalType": "ROLE", 
     "principalId": "$authenticated", 
     "permission": "ALLOW" 
    }, 
    { 
     "accessType": "*", 
     "property" : "*", 
     "principalType": "ROLE", 
     "principalId": "$unauthenticated", 
     "permission": "DENY" 
    } 
    ], 

我有一個擴展用戶的模型用戶。

我去http://localhost:3000/explorer並做POST /用戶/登錄,收到一些ID MY_TOKEN。 然而,請求 http://localhost:3000/api/my_model?access_token=MY_TOKEN

當我得到如下回應:

{ 
    "error": { 
    "name": "Error", 
    "status": 401, 
    "message": "Authorization Required", 
    "statusCode": 401, 
    "code": "AUTHORIZATION_REQUIRED", 
    "stack": "Error: Authorization Required\n at 
     bla 
    } 
} 

我試圖用DEBUG =回送:安全:*,但它不是真正的信息。

loopback:security:access-context ttl 1209600 +3ms 
    loopback:security:access-context getUserId() null +2ms 
    loopback:security:access-context isAuthenticated() false +1ms 
    loopback:security:role Custom resolver found for role $authenticated +1ms 
    loopback:security:role isInRole(): $unauthenticated +1ms 
    loopback:security:access-context ---AccessContext--- +1ms 
    loopback:security:access-context principals: [] +1ms 
    loopback:security:access-context modelName my_model +1ms 
    loopback:security:access-context modelId undefined +2ms 
    loopback:security:access-context property find +1ms 
    loopback:security:access-context method find +2ms 
    loopback:security:access-context accessType READ +1ms 
    loopback:security:access-context accessToken: +1ms 
    loopback:security:access-context id "eYKYFzfKLCF3Pq0QG8xcWjy4ZXR0fYHGLMvj6j5SbR9v30ctWaFAyXpTdFQvZ6FO" +1ms 
    loopback:security:access-context ttl 1209600 +1ms 
    loopback:security:access-context getUserId() null +1ms 
    loopback:security:access-context isAuthenticated() false +1ms 
    loopback:security:role Custom resolver found for role $unauthenticated +1ms 
    loopback:security:acl The following ACLs were searched: +2ms 
    loopback:security:acl ---ACL--- +1ms 
    loopback:security:acl model my_model +2ms 
    loopback:security:acl property * +2ms 
    loopback:security:acl principalType ROLE +2ms 
    loopback:security:acl principalId $unauthenticated +2ms 
    loopback:security:acl accessType * +1ms 
    loopback:security:acl permission DENY +1ms 
    loopback:security:acl with score: +1ms 7499 
    loopback:security:acl ---Resolved--- +1ms 
    loopback:security:access-context ---AccessRequest--- +0ms 
    loopback:security:access-context model mo_model +1ms 
    loopback:security:access-context property find +1ms 
    loopback:security:access-context accessType READ +1ms 
    loopback:security:access-context permission DENY +2ms 
    loopback:security:access-context isWildcard() false +1ms 
    loopback:security:access-context isAllowed() false +1ms 

是否有任何理由爲什麼我的身份驗證不起作用?

非常感謝!

+0

如果您通過/ explorer登錄並設置令牌,那麼這些東西是否有效? –

+0

nope。沒有得到它的工作方式。我在想,也許這是因爲用戶和my_model之間沒有定義關係? @Raymond Camden – user2717954

+0

兩者之間的關係不是必需的。事實上,你說的$認證是足夠的 - 或者*應該*就夠了。儘管getUserId返回空值是令人擔憂的事實。你的數據源是什麼? –

回答

0

我有這個相同的問題。來找出,你不能有一個id = 0的用戶。

因此,我刪除了第一個用戶,我試圖使用,並將ID更改爲1,並按預期工作。

希望這可以節省別人的麻煩。