Skip to content
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

Specify behaviour for Principal when nobody is logged in, CDI EE #841

Open
starksm64 opened this issue Feb 22, 2024 · 2 comments
Open

Specify behaviour for Principal when nobody is logged in, CDI EE #841

starksm64 opened this issue Feb 22, 2024 · 2 comments

Comments

@starksm64
Copy link
Contributor

Is your feature request related to a problem? Please describe.
From jakartaee/cdi#769,

@benjamin-confino I recently had a customer ask why we have CDI inject a Principal containing saying unauthenticated when HttpServletRequest.getUserPrincipal() will give a null in that context.

I think that unauthenticated is the correct choice for CDI, since we cannot inject a null and hope for it to remain up to date as the context changes, but I think it would be useful to clarify the spec on this point as the current behaviour is undefined.

Describe the solution you'd like
We need to clarify the behavior. From CDI-769, comment from @Ladicek:
What seems a bit weird to me is that the specification doesn't define the scope of the Principal bean. I guess it should be @RequestScoped, and that itself actually precludes a null value.

@arjantijms
Copy link
Contributor

Should we not move this to the security spec and specify it there?

A null as name may be more logical for the unauthenticated principal.

What seems a bit weird to me is that the specification doesn't define the scope of the Principal bean.

The principal should perhaps have its own scope: @AuthenticatedScope. A Principal can potentially change many times during a request, e.g. via HttpServletRequest.login, HttpServletRequest.authenticate and HttpServletRequest.logout.

@starksm64
Copy link
Contributor Author

starksm64 commented Feb 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants