-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect authentication strategy query #99
Comments
Auth dummy should only be used at development time |
There is a class of |
The developer can add a custom authentication strategy that should satisfy certain criteria: link. We can see if that is actually true. |
The const cds = require('@sap/cds')
const DummyUser = new class extends cds.User { is:()=>true }
module.exports = (req,res,next) => {
req.user = new DummyUser('dummy')
next()
} We can indeed check the above by looking at the implementation of class Privileged extends User { is(){ return true }} |
Query to find constant true functions, trying best to capture them statically: from Function function
where forall(Expr expr | expr = function.getAReturnedExpr() | expr.mayHaveBooleanValue(true))
select function |
In theory the constructor call like below can happen anywhere: const cds = require('@sap/cds')
// with user ID as string
const user = new cds.User('userId')
// a user instance
const anotherUser = new cds.User(user)
// a user instance like object
const yetAnotherUser = new cds.User({id: user.id, roles: user.roles, attr: user.attr}) But in reality it can happen either in a custom authentication middleware like this: const cds = require('@sap/cds')
const DummyUser = new class extends cds.User { is:()=>true }
module.exports = (req,res,next) => {
req.user = new DummyUser('dummy')
next()
} Or in a handler registration like this: this.before("*", function (req) {
const user = new cds.User.Privileged();
return this.tx({ user }, (tx) =>
tx.run(
INSERT.into("RequestLog").entries({
url: req._.req.url,
user: req.user.id,
}),
),
);
}); |
Relevant sources:
Source code of cds.User:
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
The text was updated successfully, but these errors were encountered: