okta / okta-auth-js

The official js wrapper around Okta's auth API
Other
447 stars 261 forks source link

Error when httpRequest deletes STATE_TOKEN_KEY_NAME from storage #1493

Open rthm93 opened 7 months ago

rthm93 commented 7 months ago

Describe the bug

The error attributes[attributeName].split is not a function was throw when I called OktaAuth.signout(). I have dug into okta-auth-js's source code and found that the error was throw from this line.

The storage.delete's implementation is found in here in browser/browserStorage.

Reproduction Steps?

The following is a min version of my AuthService in Angular:

@Injectable({
  providedIn: 'root'
})
export class AuthService {
    constructor(private oktaStateService: OktaAuthStateService, @Inject(OKTA_AUTH) private oktaAuth: OktaAuth) {}

   async logout() {
        await oktaAuth.signout();
   }
}

The following is a screenshot of my chrome debugger: image

SDK Versions

System: OS: Linux 5.15 Oracle Linux Server 8.9 CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1260P Memory: 15.21 GB / 30.65 GB Container: Yes Shell: 4.4.20 - /bin/bash Binaries: Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm Browsers: Chrome: 121.0.6167.139 npmPackages: @okta/okta-angular: ^6.3.2 => 6.3.2 @okta/okta-auth-js: ^7.5.0 => 7.5.0

Additional Information?

No response

rthm93 commented 7 months ago

The walkaround I am using now is to override the storageUtil in the OktaAuthOptions like the following:

new OktaAuth({
    ...
    storageUtil: {
        // Custom implementation
    }
})
jaredperreault-okta commented 7 months ago

Can you share your full OktaAuth config (please sanitize sensitive properties)

rthm93 commented 7 months ago

I am using OktaAngular, the following is how I provide the OktaAuth.

export const OktaConfigProvide: Provider = {
  provide: OKTA_CONFIG,
  useFactory: (appConfigService: ConfigurationService) => ({
    oktaAuth: new OktaAuth({
      issuer: appConfigService.config.oktaIssuer,
      clientId: appConfigService.config.oktaClientId,
      redirectUri: window.location.origin + '/login-callback',
      scopes: ['openid', 'profile']
    })
  }),
  deps: [ConfigurationService]
}

my app.module.ts:


@NgModule({
    imports: [..., OktaAuthModule],
    providers: [..., OktaConfigProvide]
})
export class AppModule {}
shuowu-okta commented 7 months ago

@rthm93 Thanks for reporting the issue! Our team will look into it. Internal ref: OKTA-697135