Custom keycloak login theme styles.css return error 404
Before reporting an issue
- [X] I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
login/ui
Describe the bug
I'm following Keycloak guide to create a custom login them. The custom css file is unable to fetch by Keycloak v26.0.0, error 404 is returned. It was working in v25.0.6.
Version
26.0.0
Regression
- [X] The issue is a regression
Expected behavior
styles.css should be returned
Actual behavior
response error 404
How to Reproduce?
Following this guide Creating a theme
themes
└── mytheme
└── login
├── resources
│ └── css
│ └── styles.css
└── theme.properties
- in the theme.properties file add the following lines:
parent=keycloak import=common/keycloak styles=css/styles.css
- in the styles.css file add the following lines:
.login-pf body { background: DimGrey none; }
- start keycloak server with the following command
sh kc.sh start-dev - After login, go to master Realm settings, change the login theme to mytheme
- Logout from Keycloak Admin Console
- Then Keycloak is unable fetch mytheme login styles.css
Anything else?
No response
I cannot reproduce this in 26.0.1. I have created a little theme custom like you mention (see attachment to test) except that I have added the base login.css too:
styles=css/login.css css/styles.css
And I see the login page includes both styles:
<link href="/resources/7eydk/login/custom/css/login.css" rel="stylesheet" />
<link href="/resources/7eydk/login/custom/css/styles.css" rel="stylesheet" />
And I have no issues loading the styles.css file. I see the background of the login is grey as your css is specifying. Can you please test with the attached zip (just change the extension to jar and put it in the providers folder?
@rmartinc Thank you for providing the custom.jar file. I tested it, and when I package the custom theme in a jar file, it works in versions 26.0.0 and 26.0.1. However, if I place the custom theme files directly in the themes folder, the CSS file fails to load. This setup worked in versions prior to 26.
I still cannot reproduce, I have even tested in windows, just in case. I have just done the following:
cd keycloak-26.0.1/themes/
jar xvf ../providers/custom.jar
rm ../providers/custom.jar
mv theme/custom .
rmdir theme
rm -r META-INF
cd ../bin
./kc.sh start-dev
I see the background in grey deployed as a folder theme. And the css file can be retrieved with no issues in the browser.
Does the custom theme attached before deployed in the themes folder work for you? (You just need to decompress the custom folder in themes)
What is your keycloak installation folder?
Thanks for reporting this issue, but there is insufficient information or lack of steps to reproduce.
Please provide additional details, otherwise this issue will be automatically closed within 14 days.
Hi @rmartinc
I had the same issue with this which lead me here. After few hours of research, what helped me was starting server from KEYCLOAK_HOME folder, instead of bin folder. I don't know why is this happening.
bin/kc.sh start-dev
Hope it helps.
Sorry, but I cannot reproduce the issue, it works for me when the server is started using start-dev (develompent) and start (production) and in windows and linux. No matter if I start it in the bin folder or the home folder. So I'm lost. If someone can send me exact reproducer steps (comment the environment too because maybe it's related to it), with a sample theme zip attached, it would be awesome.
Here is the theme zip. dashboard.zip In case you need more here is the full zip with setup (basic keycloak with realm and theme setup). https://drive.google.com/file/d/1ucRyupkQ29VXT3Eft0uAafsYoqy-lVsE/view?usp=sharing Admin user: admin_user Admin password: admin Under: http://0.0.0.0:8080/realms/dashboard-login/account/ the issue should be reproducible.
@arados It's working for me starting from the bin folder. I needed to fix some file names that were not correct, I suppose you didn't rename it before passing the zip file (I needed to rename to mysite-web.js for example). I have not tested in windows this time, but in my fedora laptop it's working for start and start-dev mode.
Are you using mac? (I cannot test that).
Yes, I was removing markings from client site so possible some file names were not fixed. Yes, I am running it on mac (tested on 2 macs, 2 different OS versions).
I am able to reproduce this on macOS if I run ./kc.sh start-dev from the bin directory. If I use the root directory and run ./bin/kc.sh start-dev it actually works just fine.