Compare commits
1 Commits
2a394969d2
...
9f7216565b
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f7216565b |
@@ -62,7 +62,12 @@ export class OidcService {
|
||||
return this.discoveryCache.doc;
|
||||
}
|
||||
const url = issuer.replace(/\/$/, '') + '/.well-known/openid-configuration';
|
||||
const res = await fetch(url);
|
||||
let res: Response;
|
||||
try {
|
||||
res = await fetch(url);
|
||||
} catch {
|
||||
throw new BadRequestException('oidc: issuer unreachable (discovery failed)');
|
||||
}
|
||||
if (!res.ok) throw new BadRequestException(`oidc discovery failed: ${res.status}`);
|
||||
const doc = (await res.json()) as Discovery;
|
||||
if (!doc.authorization_endpoint || !doc.token_endpoint) {
|
||||
@@ -120,11 +125,16 @@ export class OidcService {
|
||||
client_secret: c.clientSecret,
|
||||
code_verifier: st.cv,
|
||||
});
|
||||
const tokRes = await fetch(doc.token_endpoint, {
|
||||
let tokRes: Response;
|
||||
try {
|
||||
tokRes = await fetch(doc.token_endpoint, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/x-www-form-urlencoded', accept: 'application/json' },
|
||||
body: body.toString(),
|
||||
});
|
||||
} catch {
|
||||
throw new UnauthorizedException('oidc: token endpoint unreachable');
|
||||
}
|
||||
if (!tokRes.ok) {
|
||||
throw new UnauthorizedException(`oidc: token exchange failed (${tokRes.status})`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user