From 2000e9fa122e9bc4548ca0405fafcfb6d7f055b5 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sat, 1 Jun 2024 18:02:30 +0530 Subject: [PATCH] Style and add OIDC logo to the login page. --- cmd/auth.go | 49 ++++++++++++++---- i18n/en.json | 2 +- static/public/static/auth/auth0.com.png | Bin 0 -> 2873 bytes static/public/static/auth/github.com.png | Bin 0 -> 1151 bytes static/public/static/auth/google.com.png | Bin 0 -> 1625 bytes .../static/auth/microsoftonline.com.png | Bin 0 -> 199 bytes static/public/static/auth/oidc.png | Bin 0 -> 1918 bytes static/public/static/style.css | 18 ++++++- static/public/templates/login.html | 11 ++-- 9 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 static/public/static/auth/auth0.com.png create mode 100644 static/public/static/auth/github.com.png create mode 100644 static/public/static/auth/google.com.png create mode 100644 static/public/static/auth/microsoftonline.com.png create mode 100644 static/public/static/auth/oidc.png diff --git a/cmd/auth.go b/cmd/auth.go index 89d7b285..3ca81568 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -2,6 +2,7 @@ package main import ( "net/http" + "net/url" "strings" "time" @@ -15,11 +16,19 @@ type loginTpl struct { Title string Description string - NextURI string - Nonce string - PasswordEnabled bool - OIDCEnabled bool - Error string + NextURI string + Nonce string + PasswordEnabled bool + OIDCProvider string + OIDCProviderLogo string + Error string +} + +var oidcProviders = map[string]bool{ + "google.com": true, + "microsoftonline.com": true, + "auth0.com": true, + "github.com": true, } // handleLoginPage renders the login page and handles the login form. @@ -33,11 +42,33 @@ func handleLoginPage(c echo.Context) error { next = uriAdmin } + oidcProvider := "" + oidcProviderLogo := "" + if app.constants.Security.OIDC.Enabled { + oidcProviderLogo = "oidc.png" + u, err := url.Parse(app.constants.Security.OIDC.Provider) + if err == nil { + h := strings.Split(u.Hostname(), ".") + + // Get the last two h for the root domain + if len(h) >= 2 { + oidcProvider = h[len(h)-2] + "." + h[len(h)-1] + } else { + oidcProvider = u.Hostname() + } + + if _, ok := oidcProviders[oidcProvider]; ok { + oidcProviderLogo = oidcProvider + ".png" + } + } + } + out := loginTpl{ - Title: app.i18n.T("users.login"), - PasswordEnabled: true, - OIDCEnabled: true, - NextURI: next, + Title: app.i18n.T("users.login"), + PasswordEnabled: true, + OIDCProvider: oidcProvider, + OIDCProviderLogo: oidcProviderLogo, + NextURI: next, } // Login request. diff --git a/i18n/en.json b/i18n/en.json index 382442b9..a993e649 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -596,7 +596,7 @@ "templates.rawHTML": "Raw HTML", "templates.subject": "Subject", "users.login": "Login", - "users.loginOIDC": "Login with OIDC", + "users.loginOIDC": "Login with {name}", "users.logout": "Logout", "users.profile": "Profile", "users.lastLogin": "Last login", diff --git a/static/public/static/auth/auth0.com.png b/static/public/static/auth/auth0.com.png new file mode 100644 index 0000000000000000000000000000000000000000..3b2d8562d9dd443cf81e50cd9743413cc0caccdf GIT binary patch literal 2873 zcmaJ@cUY5G7Y{3n3JwIy5JO~rj0{GAKp2uBD?kw~vk;P(BuEA!Bq0b65TS@wKx8N) zpj1(aj1obXfQ8}!8L~Hs3k-@Pqy2)d_WQ$r_j%s;j_3S-=XcIM_dYk-)BS+l7S$~v z5J=A13F{^9?KZy6VDbMZHDXlUsjzWA?1PL@HkZHxK=vd?2mo=W5y*fSKp;g&v;)>4 zkdzM9+lTFgcS92yG#FvS2F9Z?#b^-7+Lp&85RU+CNC-ft(lOA5+6E|uO2R;YFvBD8 zOb38Mb>g#tgM4>yBL4`{k_5H2fmrjX+sh(H)akVq5^i83`up$s9$2xBB1VGKuF8X23Qkq9)x9P)RA zirukDp=d9xuJ#ya{ z1}qRsWKo%HDuWK$U?hYvqSzRySn6Lf(3oFo>5+fuNt`h_kHCZ@VTg^Gz8K>1|KF5G z`)VD@_5%LV`%U6V?`S3f_W~jrQ7oc(=R)^wxMHFmSO9^|V0kkb;a}3|Nnx-VkrW0K zVvK|tL-g#k7N_*M8Fw~fr?3BR4NJWh{a(o%=hCENJ|SO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eR>D-(^ODUC{t2YjQ#lxd63@-%Jhlr)S3;(?%lBip$!fmtB(!p{z(|O zzLJ@ckT7;RN_2)>xpYE1QLWN0{g>vheFx4ay_8v6TKcrVg@(#qSr$$8hE)yDhE}vD zj(Iw^$qQPT@k(9A%|hXBMMYed)~=6>9$uqUc@yia9~GSR^m(I6#(J;Xl?2C~o8?pk z;H2alO_pd9cQX^Fr?>olFqiXlmVfZskvU9WxMcbRCDXPVZO(Y(i6^J*9$&Ft$b4Nv zesWS@U%&ob4ZRQ+F07DqySg$CTg_3oF3!lv@YkTnX6?0&Q*XNcY-HrJ%i4UVScI?$Y&ZYvmFti3pDNw zphhJx-si`}JWJ=TG~|shEZCYD8y9fZZ@$)&|2@fTGElvAXRw4q|M+;hxux{k5YuE1 zu3edz+A?cv^<+50$?MRerR=Bo@2X@qaz+7=E>of80De{1q%>Jrcw*CbjkPo^*_D)< z+7S8tvDHmQCn}XXQq+-~R9tKm^CA2Yg)(<*d5@&Z31=GZO-y}#eZ}Y>E04E@GtU*; zbJ&hL>JEJV3Z9X&Nk=fVNZwW8cl+=d@wc z4_0$wd9P_bqgR)Ng@xJds0b)9e3@VRbnPA|Z%ll!Ya*r|{HQ6?i!UFYoauFy6JJ__ z^78Ub59>Gw6$Z=i{1GFqtbrN6rmp#D+{oU*oMAG=c__Qru4| Sy6xI{%sS)Tv8DTiPyQF}Gv!qP literal 0 HcmV?d00001 diff --git a/static/public/static/auth/github.com.png b/static/public/static/auth/github.com.png new file mode 100644 index 0000000000000000000000000000000000000000..1fa19c55d2f71505edf0f4d70840e817e7861c06 GIT binary patch literal 1151 zcmV-_1c3XAP)aRaZbWef~;-qbQN~T3m5@KGy*SRcU1Y@_%gT?qoIV1 z#+_K&r^Z*p_=X zkV~rhX7~W|+y`hDck^w~4$6pjXcK4iU7?KWf;Lf`Z;tj*Mzu%tC~tV5KpFQ5a$y3v z3i_Y8%G&()sD>)o4V&Xsyo>oz!sg>$oQln{8&p9xws&p52?j$IbSrY-#c&;_K{1<- z>#$gnal1hk3`P@|0B(UCJXEH}Vt4|z5QNG24X@!|T!~8nPIDPv!*7@j0o0%t7ArH} z!;phpDmA|b7C;V8bNtGD5>^fI9<(Y>!j=xVJq>cO0Be*h^gQHfKaXal`$3MLFI8j} zEP@;z>`?%RK#mq+m10F6feg;@D1b8{gGY+Z?I%J8&v+ETGmybVG|De<5Mhug4BpHyFaa{S*~3NIn;?S;|J-qX$Y3m*dKf@cjDZZ+4>&jn zGPuFxrTH5mgL4879)%3n^f-XEAcIE(4!(gLjSf8Dj4y+40uBa2j(*HQ06#*G1_c~U zh8(?>fdJly98C$FXMezJ83^Dt$kBqpy1tfy06v9W83M@6d%#cD0OmoChGZasA&{ea zfpHdCjb`NuhCv2* zgk20d&cgtX3$-Z1!7`B1P&D_b`Q{h~87&iKN$Dkz0(dFXlAis20KiQiG=B>e!X5cV z)`LQN0Zr@aGyerBr1c65c7Q?}goBYw>5p26V+a&dhhl|Kfr|JUJL6EiP+|7i3zuTG zgjRd5LO&>?Q;H4H5Tl?1qp?BW?bdPJiQ#w+SK$yeF*Mr>N8={EgE3G{MxkM;fzO4C zn2VG1ZnrcBLylfY&iFKc1xmoVkv=*)|djts1F)e8hB5r zgarjJhg+RiUQL_*j}HcWx(@t2RKhm}Pt|*%G7gLo!2VE7p0^C#vckvACIz?O7H?uO zW?(2j!YODHA%HcY7z{y6>);z<4phYZDSg>l42ozDHVV4~N0fP^J3Ipc)Z&P!J8=$F z#5^47c>w3cwIi26C47kOkn=2nOXA*{lPfGZPR6hJ3}2uFW?-?D1E|KyNj)WZ#YD&; z%>X81*QDQ=R>ZF!2JkCZOlvNl!-bgRK>%}bF>>{>8nXgkK^;`WauMn;4V6%bSFwT* zYjPXlbu5AkEFGclQc!_vyp9cg{9$4RT!#S=-ie{+I}iroI{ZE=#`q{01pu+n%tOqP Rd2;{&002ovPDHLkV1i^k^r8R& literal 0 HcmV?d00001 diff --git a/static/public/static/auth/google.com.png b/static/public/static/auth/google.com.png new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VD11)a|d>skDZ*a0T`E4enu$U_x$Z} zGCx2hAPRHGfjy}li*i{H)$hE1dn)_B&d%xuJt&DG2T!J8 z;&u8AUzDWuZK9qPhLa2dh?2<~_T{2R_DK8!GyfdS45AFc2OzMk14P-pxUFHky@$@Y z;R-2z16MCx^)wF+;38g1ly$zPa&M)g;sD=QVsWm=%?z2OGgUYUXJ zYrs8Tf#S;m2ae~mzciIK@%bBZJ5!MO5Co=XX?<-D`vUDUzX~Tmm{IYNS~0j~?8Qk; zcU)cwrMKM8KAb)k^XjbDW2uG74p=Fp@DgA&{NJvU^Yi@! Xcf1=#ExaOi00000NkvXXu0mjfwHywk literal 0 HcmV?d00001 diff --git a/static/public/static/auth/microsoftonline.com.png b/static/public/static/auth/microsoftonline.com.png new file mode 100644 index 0000000000000000000000000000000000000000..168a9c81395d5ab507ff3ec1ecfbceccfd8b89dc GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0J3?w7mbKU|e^#Gp`SN8%Rh9w^wb}{_l$?z#a ziDBvcdN_N@d!QhY3lx9NT&V}t!dVjJ7tHV;2p#}|05kJ(prD(li(`m~cd|t@Q=frB z#(OtLp2b{lqCHv?bGTvx8rYegCkb&SNbooauyz<3h)6GHXq%~#pv2sKRZGNRRYJ(Y e6-@_MGBEgft<)^auj&Ju$l&Sf=d#Wzp$PyW-9QKc literal 0 HcmV?d00001 diff --git a/static/public/static/auth/oidc.png b/static/public/static/auth/oidc.png new file mode 100644 index 0000000000000000000000000000000000000000..7b53d129f9569e45fafc481fb10f7420c9bd8742 GIT binary patch literal 1918 zcmV-^2Z8vBP)004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00006 zVoOIv0RI600RN!9r;`8x00(qQO+^Rg0t*!;5tJV`y#N3PT}ebiRCwC$+j(qUR~5(c z&y2@$Ham^eBn?eNTG|-W7A2@nOBxUnYN@Cg)&de$*#%Ms;y?C9>}5$M;19$is#1_b zQz0II@CQxVqzFQy7DGeT3J9fjiO50{JKksb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{dLL)eHD|asL1S03~!qSaf7zbY(hYa%Ew3WdJfTGBGVMGA%JNR5CF-GdMaiH!CnO zIxsN#4qMy+001R)MObuXVRU6WZEs|0W_bWIFfuVMFfuJMF;p@!Ix{#rF*hqPFgh?W zh*RTW0000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUy07*qoM6N<$ Ef>9}Yp8x;= literal 0 HcmV?d00001 diff --git a/static/public/static/style.css b/static/public/static/style.css index 8808c4b5..a47267c3 100644 --- a/static/public/static/style.css +++ b/static/public/static/style.css @@ -87,7 +87,8 @@ input[disabled] { color: #0055d4; } .button.button-outline:hover { - background-color: #0055d4; + border-color: #333; + background-color: #333; color: #fff; } @@ -181,6 +182,21 @@ input[disabled] { font-weight: bold; } +.login .submit { + margin-top: 20px; +} + .login button { + width: 100%; + vertical-align: middle; + display: flex; + align-items: center; + justify-content: center; + } + .login button img { + max-width: 24px; + margin-right: 10px; + } + #btn-back { display: none; } diff --git a/static/public/templates/login.html b/static/public/templates/login.html index 596ca2f3..b8b8524a 100644 --- a/static/public/templates/login.html +++ b/static/public/templates/login.html @@ -1,7 +1,7 @@ {{ define "admin-login" }} {{ template "header" .}} -

+