Project

General

Profile

Actions

Task #2687

closed

Implement support for SSO and SLO against CAS

Added by Roman Kučera about 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Radek Tomiška
Category:
Authentication / Authorization
Target version:
Start date:
02/15/2021
Due date:
% Done:

100%

Estimated time:
24.00 h
Owner:

Description

Ticket task:
Changing ticket task after discussion with Vítek. Written in czech for clarity, english version will follow soon.
Original ticket task is mentioned at the bottom.

Integrace IdM-CAS
Standardní integrace viz https://apereo.github.io/cas/6.2.x/protocol/CAS-Protocol.html (Web flow diagram).

UC1:
  1. Uživatel přichází na IdM, nemá CIDMST token.
  2. IdM ho přesměruje na CAS k přihlášení.
  3. Uživatel se přihlásí "do CASu", CAS ho přesměruje zpět na IdM s tokenem.
    • Pokud uživatel už je "do CASu" přihlášený, není přihlášení požadováno a dojde rovnou k přesměrování uživatele.
  4. IdM si token ověří v CASu (přímá komunikace IdM->CAS) a získá si i atributy uživatele.
  5. Na základě obdržených atributů vydá IdM uživateli svůj CIDMST token a dále se pracuje už jen s ním.
UC2:
  1. Uživatel přichází na IdM, má CIDMST token.
  2. Pokud token není platný, tak viz výše (jako by token neexistoval).
  3. Pokud je token platný, s CASem se nijak neinteraguje.
UC3:
  1. Odhlašovací button v IdM vyvolá odhlášení z IdM i CASu.
UC4:
  1. Uživatel klikne na "přihlášení jako jiný uživatel".
  2. IdM použije svou interní funkcionalitu a nijak do toho nezapojuje CAS.
  3. Uživatel je v IdM nyní přihlášen jako jiný uživatel.
UC5:
  1. Uživatel klikne na odkaz v mailu, který vede na konkrétní stránku v IdM.
  2. Pokud má uživatel platný CIDMST, projde do IdM a tma normálně pracuje jako to teď je.
  3. Pokud uživatel nemá platný CIDMST, je přesměrován na CAS k přihlášení.
  4. Po přihlášení je uživatel (ve finále) přesměrován na konkrétní stránku v IdM, na kterou se původně snažil z mailu prokliknout.
Nahromadilo se poměrně velké množství feedbacku na aktuální řešení v produktovém RM: #22187, #22102, #22129, #22398, #22409, #22410.
Výcuc ve formě nefunkčních požadavků:
  • IdM zobrazuje rozumné chybové hlášky, když se něco nepodaří.
  • IdM se při chybě ověření CAS tiketu nesnaží uživatele poslat na CAS znovu.
    • Pokud CAS vrátí korektní odpověď (byť o tom že token není platný), tak nejde o "chybu ověření tiketu".
    • Ověření tiketu IdM->CAS musí být schopno přežít transientní síťové chyby (-> něco jako několik oddělených pokusů, pokud předchozí skončily na chybě sítě). IdM nesmí zkoušet do nekonečna.
  • CAS nepodporuje anchory v URL, které IdM používá jako routy pro frontend. Je potřeba to zohlednit.
    • Myšlenka: Co celý handling externí autentizace (ať jde o CAS, Kerberos s REMOTE_USER hlavičkou, aj.) přesunout pouze na backendový endpoint?
  • Aplikační účty přistupující do IdM pomocí apikey/CIDMST tokenu (např. password filter) jsou lokální k IdM a nepodléhají autentizaci CASem.
  • IdM audituje přihlášení uživatele z externí autentizace ve svém aplikačním logu.
    • Mělo by asi jít o audit přeměny CAS tiketu na CIDMST, vč. třeba loginu z IdM a loginu z CASu.
    • Service tiket je možné v logu uvést, protože má jen krátkou platnost.
  • Alespoň rámcově mrknout, kolik validací service tiketu je potřeba... víme, že v současném řešení si Chrome/FF/Opera vystačí s jednou, IE/EDGE jich potřebují klidně 100.
    • Pokud bychom řešili externí autentizaci čistě na backendu, asi by se to tím "vyřešilo samo".
  • Podporovat režim pro explicitní přihlášení administrátora, pokud je zapojeno SSO.
    • Je otázka, zda je to jen vzhledem k CASu protože jsme to částečně potkali i s Kerberem - asi na analýzu, proto přidávám sem a kdyžtak vyhodíme. Existuje k tomu nedořešená diskuze v tiketu #22410.
    • Případně je to další UC, který musíme vydefinovat.
  • CAS integraci produktu musí jít konfiguračně zapnout pomocí application properties. By-default bude vypnutá.
    • Konfigurace bude řešena také pomocí application properties. Lze se inspirovat u stávajícího idm-cas modulu. Sada properties je tam vyhovující, ale chtěli bychom u nich vylepšit celkový handling.
    • Konfigurace musí podporovat i setup, kdy je CAS na úplně jiném serveru.
  • Implementace musí pokrývat vše, co na úrovni frontendu obsahuje stávající řešení.
    • Neměl by být problém, stávající řešení je podmnožinou specifikace výše.
    • Cilem je ze stavajícího idm-cas modulu zahodit celou frontendovou část, aby se při relinku aplikace na prostředí zákazníka mohl přesočit build frontendu a volali jsme jen přebalení backendu.
Old ticket task (up to #note-11):
The main point of this ticket is to implement feature for SSO and SLO against CAS.
The flow will be
  • access URL where IdM is running
  • if user is not authenticated redirect to CAS login page
  • login
  • user is redirect back to IdM.
  • user is authenticated

On BE we will implement filter.
On FE we will implement login in Login and Logout page.
This feature needs to be disabled be default.


Related issues

Related to IdStory Identity Manager - Task #914: Add property with FE and BE urlClosedRadek Tomiška01/17/2018

Actions
Related to IdStory Identity Manager - Task #2984: FE: Stay on log out page (configurable)ClosedRadek Tomiška10/19/2021

Actions
Actions #1

Updated by Roman Kučera about 3 years ago

  • % Done changed from 0 to 80

Implementation is in https://github.com/bcvsolutions/CzechIdMng/tree/rkucera/2687-authentication-cas
It works. I tested login in as another user and it works to.

Documentation is missing and test is missing for the filter.

New application.properties

Enable authentication filter on BE and forwarding logic on FE during log in and logout (single sign out). Default value is false if this property is not set.
Don't override this property on FE, otherwise you end up with no option how to log into IdM. If you enable it by overriding on FE and then you won't be able to log in via CAS, changing this value in env. properties will have no effect because values from FE overide has bigger priority.
Set this value only via env. properties (application properties)
idm.pub.core.cas.sso.enabled=true

Base URL where CAS is accessible. It's needed on FE and BE.
idm.pub.core.cas.url=https://nginx/cas

Suffix which is appended to idm.pub.core.cas-url for log in redirect on FE
idm.pub.core.cas.login-suffix=/login?service=

Suffix which is appended to idm.pub.core.cas-url for single sign out redirect on FE
idm.pub.core.cas.logout-suffix=/logout?service=

URL of IdM. This URL is used for redirect back after logout and for ticket validation on BE in authentication filter
idm.pub.core.cas.idm-url=https://nginx/idm/

Header name where CAS sending the ticket value, it's used on BE in authentication filter
idm.sec.core.cas.header-name=referer

Prefix for the value of header defined by idm.sec.core.cas-header-name It's used in authentication filter on BE so we will get the token directly
idm.sec.core.cas.header-prefix=https://nginx/idm/?ticket=
Actions #2

Updated by Roman Kučera about 3 years ago

As Radek suggest, I changed the names of config properties to idm.xxx.core.cas.xxx so it can be categorized in the future. Comment above was updated to new names

Actions #3

Updated by Roman Kučera about 3 years ago

Test for filter is implemented with 85% line coverage according to IntelliJ IDEA
Implemented some small improvements as show loading when user is waiting for redirect or when IdM token is expired IdM will perform logout from IdM and then CAS is checked and if user is still signed into CAS he will be signed to IdM again. This behavior is implemented, because we don't want to show the standard modal dialog when token is expired.

All changes are tested.
Now I need to create some documentation.

Actions #4

Updated by Roman Kučera about 3 years ago

  • Status changed from In Progress to Needs feedback
  • Assignee changed from Roman Kučera to Radek Tomiška
  • % Done changed from 80 to 90
Actions #5

Updated by Vít Švanda about 3 years ago

  • Target version set to 11.0.0
Actions #6

Updated by Radek Tomiška about 3 years ago

  • Status changed from Needs feedback to In Progress
  • % Done changed from 90 to 60

I did test and code review, SSO filter basically works, thx!

Review notes:
Major:
- main limitations - FE + BE have to run on the same server. FE does redirection to CAS, but response is related to BE, where referer header is used by filter and token is set to some response to FE.
- standalone CAS configuration is missing, some CAS setting is here https://wiki.czechidm.com/devel/documentation/security/dev/security#cas_authentication, but is not complete (e.g. https://www.baeldung.com/spring-security-cas-sso#cas-server-setup-installation).

Minor:
- when some property is wrongly configured, then FE is stucked (e.g. logout-suffix etc.)
- default properties could be in default profile configuration (+ with localhost usage) => just enable filter to work on localhost instalation
- BE vs. FE url in documentation is mixed up (related to design above)
- FE: this.context.store.dispatch(authenticateService.clearStorage()) - it's not a redux action. Use ~ this.context.store.dispatch(securityManager.receiveLogout(true)).
- BE: javadoc is missing (e.g. CasConfiguration)
- BE: CasConfiguration#getConfigurableType => should return "cas" (~section).
- BE: CasConfiguration#getPropertyNames => should return all configuration property names.

Actions #7

Updated by Radek Tomiška about 3 years ago

  • Status changed from In Progress to New
Actions #8

Updated by Radek Tomiška about 3 years ago

  • Target version deleted (11.0.0)
Actions #9

Updated by Radek Tomiška about 3 years ago

  • Estimated time set to 24.00 h
Actions #10

Updated by Tomáš Doischer about 3 years ago

One thing we discovered is that CAS does not handle the hash sign ('#') properly (see here https://groups.google.com/a/apereo.org/g/cas-user/c/7ER2rRA95ug/m/4FoJuIsUAAAJ). If I access

https://appliance/idm/#/login/

and login in CAS, CAS will redirect me to

https://appliance/idm/#/login/#/login/

Most browsers can deal with this but for example Safari can't.

We currently have a workaround for this behavior but it should ideally be improved when the authentication method becomes a part of IdM. One possible solution is to encode (part of) the URL containing the hash symbol.

@tomiskar, when you get to this task, can you please look into it?

Actions #12

Updated by Petr Fišer over 2 years ago

  • Description updated (diff)
Actions #13

Updated by Petr Fišer over 2 years ago

I added new task description based on feedback from separate idm-cas module which was developed for Greeno.
I suspect we will have to polish the task goal a bit. :)

Actions #14

Updated by Petr Fišer over 2 years ago

  • Description updated (diff)
Actions #15

Updated by Radek Tomiška over 2 years ago

  • Target version set to 12.0.0
Actions #16

Updated by Radek Tomiška over 2 years ago

  • Status changed from New to In Progress
Actions #17

Updated by Radek Tomiška over 2 years ago

  • Related to Task #914: Add property with FE and BE url added
Actions #18

Updated by Radek Tomiška over 2 years ago

  • Related to Task #2984: FE: Stay on log out page (configurable) added
Actions #19

Updated by Radek Tomiška over 2 years ago

  • Status changed from In Progress to Needs feedback
  • Assignee changed from Radek Tomiška to Roman Kučera
  • % Done changed from 60 to 90

Feature is fully implemented with all requirements above.

Commit:
https://github.com/bcvsolutions/CzechIdMng/commit/984931b3b8d4c30f31427cee834d71103f6eaf8d

Doc:
https://wiki.czechidm.com/devel/documentation/application_configuration/dev/backend#cas_authentication_filter

Could you please test this feature in appliance test environment and check new simplified configuration works correctly?

Actions #20

Updated by Roman Kučera over 2 years ago

I've used current develop and run this .war inside our appliance.
Tested use cases:
login
logout
cas is not available (user is informed about it)
login directly to IdM if CAS is not available as admin
login directly to IdM if CAS is not available as non admin (this is not possible a user is correctly informed about it)
login as some different user
I'll look into "know bugs" of previous solutions which was part of appliance to see if I didn't forget something, but for now it looks and works nicely. Thx for it.

Actions #21

Updated by Roman Kučera over 2 years ago

I looked into some other bugs from the previous solution in appliance and everything is fixed now.
CAS ticket validation number can be the default 1 for all browsers

Tested FF, Chrome, Edge

Access to some specific URL works for both case if you are already logged in or if you need to login first.
2FA working correctly

Actions #22

Updated by Roman Kučera over 2 years ago

  • Status changed from Needs feedback to Resolved
  • % Done changed from 90 to 100

Everything is working correctly.
Thx for this feature.

Actions #23

Updated by Radek Tomiška over 2 years ago

  • Assignee changed from Roman Kučera to Radek Tomiška
Actions #24

Updated by Radek Tomiška over 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF