@@ -125,11 +125,6 @@ public IActionResult Index()
125125 /// </exception>
126126 public async Task Login ( string clientId , string origin , string returnUrl )
127127 {
128- if ( string . IsNullOrWhiteSpace ( clientId ) || string . IsNullOrWhiteSpace ( origin ) )
129- {
130- throw new Exception ( "ClientId or origin are empty." ) ;
131- }
132-
133128 string oalhClient ;
134129 try
135130 {
@@ -140,33 +135,26 @@ public async Task Login(string clientId, string origin, string returnUrl)
140135 oalhClient = string . Empty ;
141136 }
142137
143- if ( string . IsNullOrWhiteSpace ( oalhClient ) )
138+ if ( ! string . IsNullOrWhiteSpace ( clientId ) && ! string . IsNullOrWhiteSpace ( origin ) && ! string . IsNullOrWhiteSpace ( oalhClient ) && $ "https:// { oalhClient } " . StartsWith ( origin , StringComparison . InvariantCultureIgnoreCase ) )
144139 {
145- throw new Exception ( "No OA LH client found." ) ;
146- }
147-
148- if ( ! $ "https://{ oalhClient } ". StartsWith ( origin , StringComparison . InvariantCultureIgnoreCase ) )
149- {
150- throw new Exception ( "Invalid origin" ) ;
151- }
152-
153- if ( ! string . IsNullOrWhiteSpace ( returnUrl ) )
154- {
155- this . Response . Cookies . Append (
156- ClientReturnUrlKey ,
157- returnUrl ,
158- new CookieOptions
140+ if ( ! string . IsNullOrWhiteSpace ( returnUrl ) )
159141 {
160- Expires = DateTimeOffset . Now . AddMinutes ( 5 ) ,
161- SameSite = SameSiteMode . None ,
162- HttpOnly = true ,
163- Secure = true ,
164- } ) ;
165- }
142+ this . Response . Cookies . Append (
143+ ClientReturnUrlKey ,
144+ returnUrl ,
145+ new CookieOptions
146+ {
147+ Expires = DateTimeOffset . Now . AddMinutes ( 5 ) ,
148+ SameSite = SameSiteMode . None ,
149+ HttpOnly = true ,
150+ Secure = true ,
151+ } ) ;
152+ }
166153
167- var internalReturnUrl = $ "/openathens/oacallback?clientId={ clientId } ";
168- var authProps = new AuthenticationProperties { RedirectUri = internalReturnUrl } ;
169- await this . HttpContext . ChallengeAsync ( "oidc_oa" , authProps ) ;
154+ var internalReturnUrl = $ "/openathens/oacallback?clientId={ clientId } ";
155+ var authProps = new AuthenticationProperties { RedirectUri = internalReturnUrl } ;
156+ await this . HttpContext . ChallengeAsync ( "oidc_oa" , authProps ) ;
157+ }
170158
171159 // return Content("Route is working");
172160 }
0 commit comments