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