SilentRenewService._tokenExpiring: ข้อผิดพลาดจากการลงชื่อเข้าใช้เงียบ: หน้าต่างเฟรมหมดเวลา t.error

ฉันกำลังติดตามหลักสูตร pluralsight การรักษาความปลอดภัยแอป Angular ด้วย OpenID Connect และ OAuth2 เพื่อเริ่มต้นและทำงานกับ oidc-client ใน Angular แต่ฉันพบปัญหากับโทเค็นการรีเฟรชแบบเงียบซึ่งส่ง

SilentRenewService._tokenExpiring: ข้อผิดพลาดจากการลงชื่อเข้าใช้เงียบ: หน้าต่างเฟรมหมดเวลา t.error

บนเซิร์ฟเวอร์ที่ลูกค้าอยู่

new Client
            {
                ClientId = "spa-client",
                ClientName = "Projects SPA",
                AllowedGrantTypes = GrantTypes.Implicit,
                AllowAccessTokensViaBrowser = true,
                RequireConsent = false,

                RedirectUris =           { 
                              "http://localhost:4200/assets/oidc-login-redirect.html",
                              "http://localhost:4200/assets/silent-redirect.html" 
                               },
                PostLogoutRedirectUris = { "http://localhost:4200/?postLogout=true" },
                AllowedCorsOrigins =     { "http://localhost:4200/" },

                AllowedScopes =
                {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile,
                    "projects-api"
                },
                IdentityTokenLifetime=30,
                AccessTokenLifetime=30

            }

และการกำหนดค่าบนไคลเอนต์คือ:

var config = {
  authority: 'http://localhost:4242/',
  client_id: 'spa-client',
  redirect_uri: 'http://localhost:4200/assets/oidc-login-redirect.html',
  scope: 'openid projects-api profile',
  response_type: 'id_token token',
  post_logout_redirect_uri: 'http://localhost:4200/?postLogout=true'
  userStore: new WebStorageStateStore({ store: window.localStorage }),
  automaticSilentRenew: true,
  silent_redirect_uri: 'http://localhost:4200/assets/silent-redirect.html'
};

ฉันพบวิธีแก้ปัญหาที่แนะนำจาก "Sohan" สำหรับปัญหาที่คล้ายกัน ที่นี่ (มีไว้สำหรับ azure AD โดยเฉพาะ) สิ่งนี้จึงทำให้เกิด

หน้าต่างเฟรมหมดเวลา

หรือข้อเสนอแนะในโพสต์นี้ ที่ฉันควรเพิ่มข้อมูลอ้างอิงสำหรับ Silent- เปลี่ยนเส้นทาง.html ไปยังไฟล์ angular.json ของฉัน ซึ่งไม่ได้ช่วยอะไร

ฉันใช้ Angular 7 และบน Chrome Version 73.0.3683.86 (Official Build) (64-bit)


person tony09uk    schedule 28.03.2019    source แหล่งที่มา
comment
ยากที่จะพูดอะไรเกี่ยวกับหลักสูตรบางหลักสูตรที่มีการจำกัดการเข้าถึง แต่อย่างไรก็ตาม คุณได้ตรวจสอบบันทึกทางฝั่ง IdSrv แล้วหรือยัง? อาจมีข้อมูลบางอย่างอยู่ที่นั่น คุณได้รับข้อผิดพลาดเมื่อใด (ขั้นตอนในการทำซ้ำ)   -  person d_f    schedule 29.03.2019
comment
ใช่แล้ว ไม่มีข้อผิดพลาด เหมือนจะโดนแต่ก็โดนนะ   -  person tony09uk    schedule 29.03.2019


คำตอบ (2)


อันนี้ฉันพยายามแก้ไขหลายครั้ง มันเป็นการรวมกันของ:

  • วัตถุ oidc-client.js UserManager ของฉันได้รับการเตรียมใช้งานมากกว่าหนึ่งครั้ง
  • ฉันไม่มีเส้นทาง /silent-refresh สำหรับสภาพแวดล้อมทั้งหมดของฉันที่ลงทะเบียนในตาราง IdentityServer4 ClientRedirectUris
person codeMonkey    schedule 21.04.2020

ฉันมักจะได้รับข้อผิดพลาดนี้เมื่อฉันลืมกำหนดค่า URL "การรีเฟรชแบบเงียบ"

person matteogll    schedule 27.03.2020
comment
สวัสดี matteogll ขอบคุณสำหรับคำตอบของคุณ! คุณช่วยอธิบายรายละเอียดเกี่ยวกับการกำหนดค่า URL รีเฟรชแบบเงียบ ๆ หน่อยได้ไหม? - person Brydenr; 27.03.2020
comment
ใช่ ฉันมีข้อผิดพลาดประเภทนี้เมื่อ URL SilentRefres ของฉันไม่ทำงานด้วยเหตุผลบางประการ ในกรณีของคุณ: ขั้นแรก: ตรวจสอบว่า localhost:4200/assets/silent-redirect.html สามารถเข้าถึงได้จาก IdentityServer (ไม่เช่นนั้นคุณจะเห็นข้อผิดพลาดใน server.log) ประการที่สอง: ตรวจสอบว่าในการ Silent-redirect.html การเรียก UserManager.signinSilentCallback() จะไม่มีข้อผิดพลาด - person matteogll; 30.03.2020