Working towards OpenID - Connect
- Adding id_token support - Adding bearer token header support for client api auth
This commit is contained in:
10
src/keys.ts
10
src/keys.ts
@ -15,16 +15,10 @@ export let public_key: string;
|
||||
|
||||
import * as jwt from "jsonwebtoken";
|
||||
import config from "./config";
|
||||
import * as moment from "moment";
|
||||
|
||||
export const JWTExpDur = moment.duration(6, "h");
|
||||
export function createJWT(data: any, expiration?: number) {
|
||||
export function createJWT(payload: any, options: jwt.SignOptions) {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
return jwt.sign(data, private_key, {
|
||||
expiresIn: expiration || JWTExpDur.asSeconds(),
|
||||
issuer: config.core.name,
|
||||
algorithm: "RS256"
|
||||
}, (err, token) => {
|
||||
return jwt.sign(payload, private_key, options, (err, token) => {
|
||||
if (err) reject(err)
|
||||
else resolve(token)
|
||||
});
|
||||
|
Reference in New Issue
Block a user