在 Angular Auth OIDC 配置中,"offset" 指的是客户端的时间偏移量,用于校准服务器和客户端之间的时间差。该偏移量是在客户端和服务器之间建立连接时计算出来的。
以下是一个代码示例,演示如何在 Angular Auth OIDC 配置中使用偏移量:
import { AuthConfig } from 'angular-oauth2-oidc';
export const authConfig: AuthConfig = {
issuer: 'https://my-auth-server.com',
clientId: 'clientId',
redirectUri: window.location.origin + '/home',
responseType: 'code',
scope: 'openid profile email',
showDebugInformation: true,
useSilentRefresh: true,
silentRefreshRedirectUri: window.location.origin + '/silent-refresh.html',
timeoutFactor: 0.01,
sessionChecksEnabled: true,
clearHashAfterLogin: true,
tokenEndpoint: 'https://my-auth-server.com/token',
userinfoEndpoint: 'https://my-auth-server.com/userinfo',
redirectUriProvider: {
provide: RedirectUriProvider,
useValue: {
getRedirectUri: () => window.location.origin + '/home'
}
},
disableAtHashCheck: true,
skipIssuerCheck: true,
disableOAuth2StateCheck: true,
nonceStateSeparator: ';',
customQueryParams: {
'nonce': '123456'
},
state: 'abcde',
maxIdTokenIatOffsetAllowedInSeconds: 180,
clockSkew: 30,
offset: 7200
};
在这个示例中,"offset" 属性设置为 7200。这意味着客户端时间比服务器时间晚两个小时。使用这种设置将校准服务器和客户端之间的时间差,确保时间戳匹配。