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

feat(idp): support login page background configuration #7900

Merged
merged 2 commits into from Jan 31, 2024

Conversation

brandon1024
Copy link
Contributor

Description

This revision introduces a new environment variable IDP_LOGIN_BACKGROUND_URL that overrides the default background image of the IDP login page when present.

Related Issue

Motivation and Context

First, I want to confess that I'm by no means a frontend developer. I'll happily accept any feedback :-)

One of the main motivations of this change is to get closer to improving consistency across the services that I host in my lab. It's possible to configure the PhotoPrism background image, and I wanted a similar look and feel with owncloud.

My original idea was to allow the user to upload or configure an image, but that's a fair bit of work and it doesn't need to be that complicated. Simply updating the stylesheet with an externally configurable address is good enough ™️

Discussed in #7674 was the eventual migration to another provider like Authelia, and I understand that this feature will become irrelevant when that migration happens. I think this is acceptable, and I think this small feature provides good value in the meantime 🙂

How Has This Been Tested?

Tested with and without IDP_LOGIN_BACKGROUND_URL:

$ docker build -t owncloud/ocis:dev .
$ docker run --rm -ti -p 9200:9200 --env IDP_LOGIN_BACKGROUND_URL=${MY_RESOURCE} --entrypoint sh owncloud/ocis:dev -c 'ocis init || true; ocis server'

Then, in the browser navigate to locahost:9200.

Screenshots (if appropriate):

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added (there are none!)
  • Acceptance tests added
  • Documentation ticket raised:

Copy link

update-docs bot commented Dec 7, 2023

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@brandon1024
Copy link
Contributor Author

brandon1024 commented Dec 7, 2023

Edit: fixed in #7915

Note for reviewers, I wasn't able to build the project without updating the Go version in the dockerfile. Some modules were using a newer Go version.

Here's what I was seeing:

$ docker build -t owncloud/ocis:dev .

[... truncated for brevity]

 => ERROR [build 4/4] RUN make ci-go-generate build                                                                                                                                                                                                                          1.5s
------
 > [build 4/4] RUN make ci-go-generate build:
0.459 make: Nothing to be done for 'ci-go-generate'.
0.473 go build -v -tags 'disable_crypt' -ldflags '-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -s -w -X "github.com/owncloud/ocis/v2/ocis-pkg/version.String=200f40206b" -X "github.com/owncloud/ocis/v2/ocis-pkg/version.Tag=" -X "github.com/owncloud
/ocis/v2/ocis-pkg/version.Date=20231207"' -o bin/ocis ./cmd/ocis
1.153 ../services/graph/pkg/unifiedrole/unifiedrole.go:4:2: package cmp is not in GOROOT (/usr/local/go/src/cmp)
1.153 note: imported by a module that requires go 1.21
1.153 ../services/graph/pkg/errorcode/cs3.go:4:2: package slices is not in GOROOT (/usr/local/go/src/slices)
1.153 note: imported by a module that requires go 1.21
1.159 make: *** [../.make/go.mk:102: bin/ocis] Error 1
------
Dockerfile:29
--------------------
  27 |     
  28 |     WORKDIR /ocis/ocis
  29 | >>> RUN make ci-go-generate build
  30 |     
  31 |     FROM alpine:3.18
--------------------
ERROR: failed to solve: process "/bin/sh -c make ci-go-generate build" did not complete successfully: exit code: 2

Here was the fix:

diff --git a/Dockerfile b/Dockerfile
index 48ac9f23a0..24dc73d61d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -21,7 +21,7 @@ COPY ./ /ocis/
 WORKDIR /ocis/ocis
 RUN make ci-node-generate
 
-FROM owncloudci/golang:1.20 as build
+FROM owncloudci/golang:1.21 as build
 
 COPY --from=generate /ocis /ocis

@@ -9,11 +9,18 @@ import store from './store';

import './app.css';

const root = document.getElementById('root')

// if a custome background image has been configured, use it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// if a custome background image has been configured, use it
// if a custom background image has been configured, make use of it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops 😅 Will include in the next patch

ReactDOM.render(
<React.StrictMode>
<Provider store={store as any}>
<App/>
<div className='oc-login-bg' style={bgImg ? { backgroundImage: `url(${bgImg})` } : {}}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have the attributes on the App or even deeper (slot or something), I'd like to avoid adding an extra wrapping div

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping to go that route, but I had some trouble getting the background to render when I added this directly on the App or children. I'm don't know enough about Material UI to know why that isn't working :/

I made a few adjustments though, I moved the div down to App and pass the image url as a prop. I think it's a bit cleaner, keeping the styling contained in App and out of the root component.

@@ -13,14 +14,23 @@ const LazyMain = lazy(() => import(/* webpackChunkName: "identifier-main" */ './

console.info(`Kopano Identifier build version: ${version.build}`); // eslint-disable-line no-console

const App = (): ReactElement => {
const App = ({ bgImg }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check the type again? Might be ReactNode ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely :-)

This revision introduces a new environment variable
`IDP_LOGIN_BACKGROUND_URL` that overrides the default background image
of the IDP login page when present.
@brandon1024
Copy link
Contributor Author

Rebased onto the tip of master.

@kulmann @janackermann this should be ready for re-review :-)

Copy link

sonarcloud bot commented Jan 5, 2024

Copy link
Member

@kulmann kulmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

@kulmann kulmann merged commit 7f2d2d2 into owncloud:master Jan 31, 2024
3 checks passed
ownclouders pushed a commit that referenced this pull request Jan 31, 2024
feat(idp): support login page background configuration
@brandon1024 brandon1024 deleted the idp-bg-config branch January 31, 2024 15:14
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

Successfully merging this pull request may close these issues.

[enhancement] appearance: ability to upload login page background image
3 participants