Open
Description
Relevant sources:
- CAP: Authentication Strategies: Dummy
- CWE CATEGORY: Comprehensive Categorization: Access Control
- CWE-798: Use of Hard-coded Credentials
- CWE-259: Use of Hard-coded Password
- CWE-1392: Use of Default Credentials
Source code of cds.User:
class User {
constructor (_) {
if (_ === undefined) {
if (new.target === Privileged) return
if (new.target === Anonymous) return
else return new User.default
}
if (typeof _ === 'string') { this.id = _; return }
for (let each in _) super[each === '_roles' ? 'roles' : each] = _[each] // overrides getters
const roles = this.hasOwnProperty('roles') && this.roles // eslint-disable-line no-prototype-builtins
if (Array.isArray(roles)) this.roles = roles.filter(r => !PSEUDO_ROLES.includes(r)).reduce ((p,n)=>{p[n]=1; return p},{})
else PSEUDO_ROLES.forEach(r => delete this.roles[r])
}
get attr() { return super.attr = {} }
get roles(){ return super.roles = {} }
get _roles(){ return this.roles } // compatibility
is (role) {
return role === 'any' ||
role === 'identified-user' ||
role === 'system-user' && this._is_system ||
role === 'internal-user' && this._is_internal ||
role === 'authenticated-user' ||
!!this.roles[role]
}
valueOf() { return this.id }
}
The above source shows that 'any', 'identified-user', 'system-user', 'internal-user', and 'authenticated-user' are built-in, hardcoded.
Relevant documentation: CAP: Authorization: Pseudo Roles
Metadata
Metadata
Assignees
Labels
No labels