本文整理匯總了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)
}