simplesamlphp / simplesamlphp/simplesamlphp

Re-authentication and logout handlers

Đang mở
#1,522 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
PHP
Star
1.1k
Fork
704
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
4

Mô tả

Problem
I'm implementing logout for OpenID Connect (OIDC) module https://github.com/simplesamlphp/simplesamlphp-module-oidc/.

We use \SimpleSAML\Auth\Simple::login($authSourceId) for authn. During user authn, we save association with particular Relying Party (RP, Service Provider (SP) counterpart in SAML) using \SimpleSAML\Session::setData(...). We also register a static logout handler function using \SimpleSAML\Session::registerLogoutHandler(...).

In registered logout handler function we retrieve all saved RP associations and send an OIDC logout requests to them so that each RP can clear their local session.

Up to now, this all works fine - whenever I call $session->doLogout($authSourceId), registered logout handler gets called and logout requests to RPs are successfully sent.

However, I have problems with re-authentication. For instance, OIDC client can request authentication using promt=login parameter even if the user is already authenticated (similar to 'forceAuthn' in SAML).

So, when I get promt=login, I do authentication again using - \SimpleSAML\Auth\Simple::login($authSourceId). However, the problem is - in the process, it comes down to \SimpleSAML\Session::doLogin($authSourceId), and in that method there is a check

if (isset($this->authData[$authority])) {
    // we are already logged in, log the user out first
    $this->doLogout($authority);
}

So, the logout gets called, and again, my logout handler gets called which in turn sends logout requests to all RPs (which I don't actually want for re-authentication)...

In short, the problem is that if I try to re-authenticate (call login if user is already authenticated), session logout is called which in turn calls any session logout handlers registered (I didn't expect that logout would be called if I do re-authentication).

Describe the solution you'd like
I would like to implement logout solution that would gracefully do logout and re-authentication for any used protocol (SAML, CAS, OIDC... meaning If user logs out of SAML SP, it would also log him out of any OIDC RP, etc., and vice-versa).

Since SAML logout implementation part currently does not register logout handlers, but handles logout separately, I would like to at least achieve that my OIDC logout handlers only get called when the 'real logout' is initiated, and not for re-authentication. It seems to me that this would be possible if the 'session cleaning' needed for re-authentication would be implemented in a way separate from the 'real logout', so that any registered logout handler would not be called for re-authentication.

This way I guess I would at least be able to achieve that if user is logged in to SAML SP and OIDC RP, if he initiates logout using SAML, my logout handlers would be called and so he would be logged out of any OIDC RPs (however, if he initiates logout from OIDC, he would not be logged out from SAML SPs, since there is no SAML logout handler registration thingy....).

Describe alternatives you've considered
Since registered logout handlers get called in re-authentication scenarios (and since no arguments are passed to logout handlers for context reasons or similar), I currently do OIDC logout, that is send OIDC logout requests to RPs only if logout is initiated using OIDC protocol, which I guess is a shame...

Additional context
Related question on ssp-user group: https://groups.google.com/g/simplesamlphp/c/-uhiVE8TaF4/m/ytCDPJc3AgAJ

OIDC login method: https://github.com/simplesamlphp/simplesamlphp-module-oidc/blob/2310ccd7c34003047199cd12632ff967bcbf53f9/lib/Services/AuthenticationService.php#L99

OIDC logout handler method: https://github.com/simplesamlphp/simplesamlphp-module-oidc/blob/2310ccd7c34003047199cd12632ff967bcbf53f9/lib/Controller/LogoutController.php#L135

Best regards and thank you for the great work on SimpleSAMLphp!

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách lần theo SimpleSAML\Auth\Simple::login(), Session::doLogin(), Session::doLogout() và Session::registerLogoutHandler(). Xem lại OIDC AuthenticationService.php và LogoutController.php được tham chiếu để hiểu các handler hiện tại. Done phải phân biệt việc dọn dẹp phiên xác thực lại với một lần logout thực sự, đồng thời duy trì hành vi của các logout-handler trên các giao thức được hỗ trợ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
php
Lĩnh vực
authentication
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.