-
Notifications
You must be signed in to change notification settings - Fork 104
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
Auth explanation request #1483
Auth explanation request #1483
Conversation
thanks! some references where really outdated + i tried to clarify in #1493 does that make it clearer? best, |
Thanks @sjvans this looks a lot better! I just miss some pointers on the |
the anonymous and privileged users should be checked via system/ technical users, on the other hand, are identified via a pseudo role and should be checked via best, |
for a privileged user, the btw, why do you need to know if it is the anonymous user? non-anonymous users have pseudo role |
I tried to use cds.User.Anonymous in a test today, but I am having trouble. In the middleware I check if user is anonymous with this code: if (!cds.context?.user.is('authenticated-user')) {
next();
return;
} In the test I would expect to use something like it('handles request with anonymous user correctly', async () => {
cds.context = { user: new cds.User('anonymous') } as EventContext;
const nextMock = jest.fn();
await initUser({} as XssecExpressRequest, {}, nextMock);
expect(cds.context.user.id).toBe('anonymous');
expect(nextMock).toHaveBeenCalledWith();
}); It would be more convenient to use |
|
@sjvans is this a new feature? We are on cds 8.5.0 and I get |
no. that's been there a long time. the sealed instances were added in v6.0.0, the classes are even a lot older. cf. node repl: Welcome to Node.js v22.8.0.
Type ".help" for more information.
> const cds = require('@sap/cds')
undefined
> cds.User
[Function: exports] {
default: [Getter/Setter],
anonymous: Anonymous {},
Anonymous: [class Anonymous extends User],
privileged: Privileged {},
Privileged: [class Privileged extends User],
_default: Anonymous {}
}
> cds.User.Anonymous
[class Anonymous extends User]
> cds.User.anonymous
Anonymous {} @daogrady could you please assist re typescript? |
Gladly! Feel free to just send me a meeting request so we can work this out. |
This is unfinished text, so please do not merge.
When migrating to CDSv8 (from 7) we did have a few issues, especially on middleware related to the user.
Please update your documentation, it is missing these points currently afaik.