@@ -51,7 +51,7 @@ func Start(c echo.Context) error {
5151 inst .Logger ().WithNamespace ("oidc" ).Infof ("Start error: %s" , err )
5252 return renderError (c , nil , http .StatusNotFound , "Sorry, the context was not found." )
5353 }
54- u , err := makeStartURL (inst .Domain , c .QueryParam ("redirect" ), c .QueryParam ("confirm_state" ), "" , conf )
54+ u , err := makeStartURL (inst , inst .Domain , c .QueryParam ("redirect" ), c .QueryParam ("confirm_state" ), "" , conf )
5555 if err != nil {
5656 return renderError (c , nil , http .StatusNotFound , "Sorry, the server is not configured for OpenID Connect." )
5757 }
@@ -66,7 +66,7 @@ func StartFranceConnect(c echo.Context) error {
6666 inst .Logger ().WithNamespace ("oidc" ).Infof ("StartFranceConnect error: %s" , err )
6767 return renderError (c , nil , http .StatusNotFound , "Sorry, the context was not found." )
6868 }
69- u , err := makeStartURL (inst .Domain , c .QueryParam ("redirect" ), c .QueryParam ("confirm_state" ), "" , conf )
69+ u , err := makeStartURL (inst , inst .Domain , c .QueryParam ("redirect" ), c .QueryParam ("confirm_state" ), "" , conf )
7070 if err != nil {
7171 return renderError (c , nil , http .StatusNotFound , "Sorry, the server is not configured for OpenID Connect." )
7272 }
@@ -81,7 +81,7 @@ func Sharing(c echo.Context) error {
8181 inst .Logger ().WithNamespace ("oidc" ).Infof ("Start error: %s" , err )
8282 return renderError (c , nil , http .StatusNotFound , "Sorry, the context was not found." )
8383 }
84- u , err := makeSharingStartURL (inst . Domain , c .QueryParam ("sharingID" ), c .QueryParam ("state" ), conf , inst .ContextName )
84+ u , err := makeSharingStartURL (inst , c .QueryParam ("sharingID" ), c .QueryParam ("state" ), conf , inst .ContextName )
8585 if err != nil {
8686 return renderError (c , nil , http .StatusNotFound , "Sorry, the server is not configured for OpenID Connect." )
8787 }
@@ -96,7 +96,7 @@ func SharingPublic(c echo.Context) error {
9696 inst .Logger ().WithNamespace ("oidc" ).Infof ("Start error: %s" , err )
9797 return renderError (c , nil , http .StatusNotFound , "Sorry, the server is not configured for OpenID Connect." )
9898 }
99- u , err := makeSharingStartURL (inst . Domain , c .QueryParam ("sharingID" ), c .QueryParam ("state" ), conf , contextName )
99+ u , err := makeSharingStartURL (inst , c .QueryParam ("sharingID" ), c .QueryParam ("state" ), conf , contextName )
100100 if err != nil {
101101 return renderError (c , nil , http .StatusNotFound , "Sorry, the server is not configured for OpenID Connect." )
102102 }
@@ -133,7 +133,7 @@ func BitwardenStart(c echo.Context) error {
133133 if err != nil {
134134 return renderError (c , nil , http .StatusNotFound , "Sorry, the context was not found." )
135135 }
136- u , err := makeStartURL ("" , redirectURI , "" , contextName , conf )
136+ u , err := makeStartURL (nil , "" , redirectURI , "" , contextName , conf )
137137 if err != nil {
138138 return renderError (c , nil , http .StatusNotFound , "Sorry, the server is not configured for OpenID Connect." )
139139 }
@@ -852,7 +852,20 @@ func getFranceConnectConfig(context string) (*Config, error) {
852852 return config , nil
853853}
854854
855- func makeStartURL (domain , redirect , confirm , oidcContext string , conf * Config ) (string , error ) {
855+ func getLoginHint (inst * instance.Instance ) string {
856+ if inst == nil {
857+ return ""
858+ }
859+ if inst .OldDomain != "" {
860+ return inst .OldDomain
861+ }
862+ if inst .OIDCID != "" {
863+ return inst .OIDCID
864+ }
865+ return ""
866+ }
867+
868+ func makeStartURL (inst * instance.Instance , domain , redirect , confirm , oidcContext string , conf * Config ) (string , error ) {
856869 u , err := url .Parse (conf .AuthorizeURL )
857870 if err != nil {
858871 return "" , err
@@ -868,8 +881,9 @@ func makeStartURL(domain, redirect, confirm, oidcContext string, conf *Config) (
868881 vv .Add ("redirect_uri" , conf .RedirectURI )
869882 vv .Add ("state" , state .id )
870883 vv .Add ("nonce" , state .Nonce )
871- if domain != "" {
872- vv .Add ("login_hint" , domain )
884+ loginHint := getLoginHint (inst )
885+ if loginHint != "" {
886+ vv .Add ("login_hint" , loginHint )
873887 }
874888 if conf .Provider == FranceConnectProvider {
875889 vv .Add ("acr_values" , "eidas1" )
@@ -878,12 +892,12 @@ func makeStartURL(domain, redirect, confirm, oidcContext string, conf *Config) (
878892 return u .String (), nil
879893}
880894
881- func makeSharingStartURL (domain , sharingID , sharingState string , conf * Config , contextName string ) (string , error ) {
895+ func makeSharingStartURL (inst * instance. Instance , sharingID , sharingState string , conf * Config , contextName string ) (string , error ) {
882896 u , err := url .Parse (conf .AuthorizeURL )
883897 if err != nil {
884898 return "" , err
885899 }
886- state := newSharingStateHolder (domain , sharingID , sharingState , conf .Provider , contextName )
900+ state := newSharingStateHolder (inst . Domain , sharingID , sharingState , conf .Provider , contextName )
887901 if err = getStorage ().Add (state ); err != nil {
888902 return "" , err
889903 }
@@ -894,8 +908,9 @@ func makeSharingStartURL(domain, sharingID, sharingState string, conf *Config, c
894908 vv .Add ("redirect_uri" , conf .RedirectURI )
895909 vv .Add ("state" , state .id )
896910 vv .Add ("nonce" , state .Nonce )
897- if domain != "" {
898- vv .Add ("login_hint" , domain )
911+ loginHint := getLoginHint (inst )
912+ if loginHint != "" {
913+ vv .Add ("login_hint" , loginHint )
899914 }
900915 if conf .Provider == FranceConnectProvider {
901916 vv .Add ("acr_values" , "eidas1" )
@@ -1343,7 +1358,7 @@ func LoginDomainHandler(c echo.Context, contextName string) error {
13431358 if err != nil {
13441359 return renderError (c , nil , http .StatusNotFound , "Sorry, the context was not found." )
13451360 }
1346- u , err := makeStartURL (r .Host , "" , "" , "" , conf )
1361+ u , err := makeStartURL (nil , r .Host , "" , "" , "" , conf )
13471362 if err != nil {
13481363 return renderError (c , nil , http .StatusNotFound , "Sorry, the server is not configured for OpenID Connect." )
13491364 }
0 commit comments