Skip to content

Commit e9dd6ff

Browse files
committed
Rework banner logo height to use named sizes instead of pixels
Replace the uint pixel value with a string enum (small/normal/big) mapping to 12/24/48px respectively. Default remains normal (24px). This avoids inline styles blocked by CSP and uses predefined MUI CSS classes instead.
1 parent b052fc9 commit e9dd6ff

8 files changed

Lines changed: 18 additions & 12 deletions

File tree

bootstrap/bootstrap.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,8 @@ func (bs *bootstrap) initialize(settings *Settings) error {
257257
}
258258
bs.config.IdentifierDefaultBannerLogo = b
259259
}
260-
if settings.IdentifierDefaultBannerLogoHeight != 0 {
261-
h := settings.IdentifierDefaultBannerLogoHeight
262-
bs.config.IdentifierDefaultBannerLogoHeight = &h
260+
if settings.IdentifierDefaultBannerLogoHeight != "" {
261+
bs.config.IdentifierDefaultBannerLogoHeight = &settings.IdentifierDefaultBannerLogoHeight
263262
}
264263
if settings.IdentifierDefaultSignInPageText != "" {
265264
bs.config.IdentifierDefaultSignInPageText = &settings.IdentifierDefaultSignInPageText

bootstrap/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type Config struct {
5050
IdentifierAuthoritiesConf string
5151
IdentifierScopesConf string
5252
IdentifierDefaultBannerLogo []byte
53-
IdentifierDefaultBannerLogoHeight *uint
53+
IdentifierDefaultBannerLogoHeight *string
5454
IdentifierDefaultSignInPageText *string
5555
IdentifierDefaultLogoTargetURI *string
5656
IdentifierDefaultUsernameHintText *string

bootstrap/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Settings struct {
4343
IdentifierRegistrationConf string
4444
IdentifierScopesConf string
4545
IdentifierDefaultBannerLogo string
46-
IdentifierDefaultBannerLogoHeight uint
46+
IdentifierDefaultBannerLogoHeight string
4747
IdentifierDefaultSignInPageText string
4848
IdentifierDefaultLogoTargetURI string
4949
IdentifierDefaultUsernameHintText string

cmd/licod/serve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func commandServe() *cobra.Command {
8989
serveCmd.Flags().StringVar(&cfg.IdentifierRegistrationConf, "identifier-registration-conf", "", "Path to a identifier-registration.yaml configuration file")
9090
serveCmd.Flags().StringVar(&cfg.IdentifierScopesConf, "identifier-scopes-conf", "", "Path to a scopes.yaml configuration file")
9191
serveCmd.Flags().StringVar(&cfg.IdentifierDefaultBannerLogo, "identifier-default-banner-logo", "", "Path to a default banner logo that appears on sign-in page.")
92-
serveCmd.Flags().UintVar(&cfg.IdentifierDefaultBannerLogoHeight, "identifier-default-banner-logo-height", 0, "Height in pixels of the banner logo on the sign-in page (default 24).")
92+
serveCmd.Flags().StringVar(&cfg.IdentifierDefaultBannerLogoHeight, "identifier-default-banner-logo-height", "", "Size of the banner logo on the sign-in page (small, normal, big; default normal).")
9393
serveCmd.Flags().StringVar(&cfg.IdentifierDefaultSignInPageText, "identifier-default-sign-in-page-text", "", "Default text that appears at the bottom of the sign-in box.")
9494
serveCmd.Flags().StringVar(&cfg.IdentifierDefaultLogoTargetURI, "identifier-default-logo-target-url", "", "Default URL for the logo of the login page.")
9595
serveCmd.Flags().StringVar(&cfg.IdentifierDefaultUsernameHintText, "identifier-default-username-hint-text", "", "Default string that shows as the hint in the username textbox on the sign-in screen.")

identifier/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type Config struct {
4747
SignedOutEndpointURI *url.URL
4848

4949
DefaultBannerLogo []byte
50-
DefaultBannerLogoHeight *uint
50+
DefaultBannerLogoHeight *string
5151
DefaultSignInPageText *string
5252
DefaultSignInPageLogoURI *string
5353
DefaultUsernameHintText *string

identifier/identifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ type Identifier struct {
8686
meta *meta.Meta
8787

8888
defaultBannerLogo *string
89-
defaultBannerLogoHeight *uint
89+
defaultBannerLogoHeight *string
9090

9191
onSetLogonCallbacks []func(ctx context.Context, rw http.ResponseWriter, user identity.User) error
9292
onUnsetLogonCallbacks []func(ctx context.Context, rw http.ResponseWriter) error

identifier/meta/branding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package meta
2020
// Branding is a container to hold identifier branding meta data.
2121
type Branding struct {
2222
BannerLogo *string `json:"bannerLogo,omitempty"`
23-
BannerLogoHeight *uint `json:"bannerLogoHeight,omitempty"`
23+
BannerLogoHeight *string `json:"bannerLogoHeight,omitempty"`
2424
SignInPageText *string `json:"signinPageText,omitempty"`
2525
UsernameHintText *string `json:"usernameHintText,omitempty"`
2626
SignInPageLogoURI *string `json:"signinPageLogoURI,omitempty"`

identifier/src/components/ResponsiveScreen.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ const styles = theme => ({
2828
dialog: {
2929
maxWidth: 440,
3030
},
31-
logo: {
31+
logoSmall: {
32+
height: 12,
33+
},
34+
logoNormal: {
3235
height: 24,
3336
},
37+
logoBig: {
38+
height: 48,
39+
},
3440
actions: {
3541
marginTop: -40,
3642
minHeight: 45,
@@ -55,9 +61,10 @@ const ResponsiveScreen = (props) => {
5561
} = props;
5662

5763
const bannerLogoSrc = branding?.bannerLogo ? branding.bannerLogo : Logo;
58-
const bannerLogoHeight = branding?.bannerLogoHeight || 24;
64+
const logoSizeClassMap = { small: classes.logoSmall, normal: classes.logoNormal, big: classes.logoBig };
65+
const logoClassName = logoSizeClassMap[branding?.bannerLogoHeight] || classes.logoNormal;
5966
const logo = withoutLogo ? null :
60-
<DialogContent><img src={bannerLogoSrc} className={classes.logo} style={{ height: bannerLogoHeight }} alt=""/></DialogContent>;
67+
<DialogContent><img src={bannerLogoSrc} className={logoClassName} alt=""/></DialogContent>;
6168

6269
const content = loading ? <Loading/> : (withoutPadding ? children : <DialogContent>{children}</DialogContent>);
6370

0 commit comments

Comments
 (0)