本文整理汇总了TypeScript中idam/oAuthHelper.OAuthHelper类的典型用法代码示例。如果您正苦于以下问题:TypeScript OAuthHelper类的具体用法?TypeScript OAuthHelper怎么用?TypeScript OAuthHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OAuthHelper类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Cookies
ErrorHandling.apply(async (req: express.Request,
res: express.Response,
next: express.NextFunction): Promise<void> => {
const cookies = new Cookies(req, res)
let user
try {
const authenticationToken = await getAuthToken(req)
if (authenticationToken) {
user = await IdamClient.retrieveUserFor(authenticationToken)
res.locals.isLoggedIn = true
res.locals.user = user
setAuthCookie(cookies, authenticationToken)
}
} catch (err) {
return loginErrorHandler(req, res, cookies, next, err)
}
if (res.locals.isLoggedIn) {
if (isDefendantFirstContactPinLogin(req)) {
// re-set state cookie as it was cleared above, we need it in this case
cookies.set(stateCookieName, req.query.state)
return res.redirect(FirstContactPaths.claimSummaryPage.uri)
} else {
await claimStoreClient.linkDefendant(user)
res.redirect(await retrieveRedirectForLandingPage(req, res))
}
} else {
if (res.locals.code) {
trackCustomEvent('Authentication token undefined (jwt defined)',
{ requestValue: req.query.state })
}
res.redirect(OAuthHelper.forLogin(req, res))
}
}))
示例2: getOAuthAccessToken
async function getOAuthAccessToken (req: express.Request, receiver: RoutablePath): Promise<string> {
if (req.query.state !== OAuthHelper.getStateCookie(req)) {
trackCustomEvent('State cookie mismatch (citizen)',
{
requestValue: req.query.state,
cookieValue: OAuthHelper.getStateCookie(req)
})
}
const authToken: AuthToken = await IdamClient.exchangeCode(
req.query.code,
buildURL(req, receiver.uri)
)
if (authToken) {
return authToken.accessToken
}
return Promise.reject()
}
示例3: loginErrorHandler
function loginErrorHandler (req: express.Request,
res: express.Response,
cookies: Cookies,
next: express.NextFunction,
err: Error,
receiver: RoutablePath = AppPaths.receiver) {
if (hasTokenExpired(err)) {
cookies.set(sessionCookie)
logger.debug(`Protected path - expired auth token - access to ${req.path} rejected`)
return res.redirect(OAuthHelper.forLogin(req, res, receiver))
}
cookies.set(stateCookieName, '')
return next(err)
}
示例4: renderView
ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
const form: Form<ClaimReference> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
if (isCCBCCaseReference(form.model.reference)) {
return res.redirect(mcolUrl)
}
const linked: boolean = await claimStoreClient.isClaimLinked(form.model.reference)
if (linked) {
return res.redirect(AppPaths.homePage.uri)
}
res.redirect(OAuthHelper.forPin(req, res, form.model.reference.toUpperCase()))
}
}))
示例5: accessDeniedCallback
function accessDeniedCallback (req: express.Request, res: express.Response): void {
res.redirect(OAuthHelper.forLogin(req, res))
}
示例6: receiverPath
function receiverPath (req: express.Request, res: express.Response): string {
return `${OAuthHelper.forUplift(req, res)}&jwt=${JwtExtractor.extract(req)}`
}
示例7: getClaimRef
private static getClaimRef (req: express.Request): string {
return OAuthHelper.getStateCookie(req)
}