mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-08 21:10:05 +00:00
fix: sas9 public access denied handling
This commit is contained in:
@@ -136,7 +136,17 @@ export class AuthManager {
|
||||
|
||||
if (isLoggedIn) {
|
||||
if (this.serverType === ServerType.Sas9) {
|
||||
await this.performCASSecurityCheck()
|
||||
const casSecurityCheckResponse = await this.performCASSecurityCheck()
|
||||
|
||||
if (isPublicAccessDenied(casSecurityCheckResponse.result)) {
|
||||
isLoggedIn = false
|
||||
|
||||
return {
|
||||
isLoggedIn,
|
||||
userName: this.userName || '',
|
||||
errorMessage: 'Public access has been denied.'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.loginCallback()
|
||||
@@ -151,7 +161,7 @@ export class AuthManager {
|
||||
private async performCASSecurityCheck() {
|
||||
const casAuthenticationUrl = `${this.serverUrl}/SASStoredProcess/j_spring_cas_security_check`
|
||||
|
||||
await this.requestClient.get<string>(
|
||||
return await this.requestClient.get<string>(
|
||||
`/SASLogon/login?service=${casAuthenticationUrl}`,
|
||||
undefined
|
||||
)
|
||||
@@ -361,3 +371,7 @@ const isLogInSuccess = (serverType: ServerType, response: any): boolean => {
|
||||
|
||||
return /You have signed in/gm.test(response)
|
||||
}
|
||||
|
||||
const isPublicAccessDenied = (response: any): boolean => {
|
||||
return /Public access has been denied/gm.test(response)
|
||||
}
|
||||
|
||||
@@ -187,6 +187,12 @@ export class WebJobExecutor extends BaseJobExecutor {
|
||||
{ result: jsonResponse, log: res.log },
|
||||
extraResponseAttributes
|
||||
)
|
||||
|
||||
if (this.isPublicAccessDenied(jsonResponse))
|
||||
reject(
|
||||
new ErrorResponse('Public access has been denied', responseObject)
|
||||
)
|
||||
|
||||
resolve(responseObject)
|
||||
})
|
||||
.catch(async (e: Error) => {
|
||||
@@ -262,4 +268,8 @@ export class WebJobExecutor extends BaseJobExecutor {
|
||||
}
|
||||
return uri
|
||||
}
|
||||
|
||||
private isPublicAccessDenied = (response: string): boolean => {
|
||||
return /Public access has been denied/gm.test(response)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ export interface LoginOptions {
|
||||
export interface LoginResult {
|
||||
isLoggedIn: boolean
|
||||
userName: string
|
||||
errorMessage?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user