georchestra / georchestra-cas-server

Apache License 2.0
0 stars 3 forks source link

custom login/logout pages for normal humans #6

Closed fvanderbiest closed 2 years ago

fvanderbiest commented 2 years ago

Hiding scary stuff for "normal humans" like this array: image

fvanderbiest commented 2 years ago

I'd like to go further, like customizing the "login again after logout" link, which currently leads to /cas/login while /?login would be expected instead. Leaving this to whoever knows how to do it (no time to dig for now).

tkohr commented 2 years ago

Hum, I had a look at this, but couldn't figure it out. Can't even see the modifications to the logout page applied (like deleting the security phrase). I think login and logout folders should go into georchestra folder/theme. But even moving them doesn't help. Does this work on your side?

Two other questions:

fvanderbiest commented 2 years ago

I think login and logout folders should go into georchestra folder/theme

right, my bad. untested ...

fvanderbiest commented 2 years ago
  • Is there a way I can access the casGenericSuccessView.html in the browser?

Yes, by accessing directly /cas/login and authenticating.

  • Why did you add the message_properties_* files?

Because I wanted to remove a weird sentence like "please have a look at this ugly array" (in the above case)

tkohr commented 2 years ago
  • Is there a way I can access the casGenericSuccessView.html in the browser?

Yes, by accessing directly /cas/login and authenticating.

Yes, once it's deployed, but I couldn't get to the view within this repo to test:-(

fvanderbiest commented 2 years ago

Tobias, would you be able to take over this PR and make the obvious changes (eg: relocating the files) ? Would be awesome. To check everything works as expected, you can use the docker image from this PR and check locally using a reduced version of the official docker composition (https://github.com/georchestra/docker) with only cas, sp, traefik, header, ldap, postgres.

tkohr commented 2 years ago

Yep, I'll have a look at this again later and try to get it working.

tkohr commented 2 years ago

Added two commits, but still can't get the modifications displayed :-(

fvanderbiest commented 2 years ago

Added two commits, but still can't get the modifications displayed :-(

@pmauduit to the rescue ?

pmauduit commented 2 years ago

After having live-debugged a bit (as it does not seem to be documented out there, or the doc is not quite clear on where the templates should be copied), I stumbled upon the following class: https://github.com/apereo/cas/blob/master/support/cas-server-support-thymeleaf/src/main/java/org/apereo/cas/web/view/ThemeClassLoaderTemplateResolver.java#L40

And figured out that the expected template locations were not correct (maybe because in a other versions of CAS, they have been moved ?):

the above class is already responsible of figuring out which template to use given the default configured theme.

After setting the file in the expected location, I get the following 500 though:

org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing org.springframework.webflow.action.ViewFactoryActionAdapter@68424ada in state 'logoutView' of flow 'logout' -- action execution attributes were 'map[[empty]]'
    at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:62)
[...]
Caused by: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [georchestra/layout], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "georchestra/casLogoutView" - line 2, col 64)

Which means:

  1. at least it's now resolving the expected file
  2. we might need to grab other resources from the default theme
pmauduit commented 2 years ago

FYI just creating an empty layout.html file fixes the issue (and I can see your "blablu" paragraph from https://github.com/georchestra/georchestra-cas-server/pull/6/files#diff-51133fe5ec56488f0f51d370a20609e57d874d4abd62f0d0b1f3f2849e087645R24 ;-))

fvanderbiest commented 2 years ago

Excellent, thanks Pierre !

tkohr commented 2 years ago

Ah, thanks @pmauduit for the rescue! This should "unblock" me :-)

tkohr commented 2 years ago

Ok, so I moved casLogoutView.html and casGenericSuccessView.html accordingly and added layout.html and includes.html which were necessary to make the templates work.

In the casLogoutView.html the modifications are getting applied now, casGenericSuccessView.html remains untested, as I could not connect via CAS 6 within the georchestra docker compo. Tried to adapt the datadir accordingly, but without success. @pmauduit could you have a look at this?

pmauduit commented 2 years ago

@pmauduit could you have a look at this?

Checking the current state of your branch, there is still something wrong in the template:

Screenshot from 2022-02-14 12-25-03

Here is the stacktrace I obtained:

Caused by: org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/georchestra/casGenericSuccessView.html]")
[...]
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "service.serviceId" (template: "georchestra/casGenericSuccessView" - line 136, col 61)
[...]
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'serviceId' cannot be found on null
pmauduit commented 2 years ago

@tkohr I think you should remove the commented out portions of the file (that's what git is about anyway, and since thymeleaf will still process commented html code, it still can fail).

pmauduit commented 2 years ago

@tkohr I pushed another commit to get closer to what you wanted to do, does it look ok to you ?

pmauduit commented 2 years ago

Here is the result at runtime btw: Screenshot from 2022-02-14 13-06-34

pmauduit commented 2 years ago

Checking the casLogout template again, and I think we should be good to go

pmauduit commented 2 years ago

Ok, seems working: Screenshot from 2022-02-14 15-55-25