-
-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use oidc-client-ts during oidc discovery * export new type for auth config * deprecate generateAuthorizationUrl in favour of generateOidcAuthorizationUrl * testing util for oidc configurations * test generateOidcAuthorizationUrl * lint * test discovery * dont pass whole client wellknown to oidc validation funcs * add nonce * use client userState for homeserver
- Loading branch information
Kerry
authored
Jul 9, 2023
1 parent
b606d1e
commit b8fa030
Showing
10 changed files
with
432 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
Copyright 2023 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { OidcClientConfig } from "../../src"; | ||
import { ValidatedIssuerMetadata } from "../../src/oidc/validate"; | ||
|
||
/** | ||
* Makes a valid OidcClientConfig with minimum valid values | ||
* @param issuer used as the base for all other urls | ||
* @returns OidcClientConfig | ||
*/ | ||
export const makeDelegatedAuthConfig = (issuer = "https://auth.org/"): OidcClientConfig => { | ||
const metadata = mockOpenIdConfiguration(issuer); | ||
|
||
return { | ||
issuer, | ||
account: issuer + "account", | ||
registrationEndpoint: metadata.registration_endpoint, | ||
authorizationEndpoint: metadata.authorization_endpoint, | ||
tokenEndpoint: metadata.token_endpoint, | ||
metadata, | ||
}; | ||
}; | ||
|
||
/** | ||
* Useful for mocking <issuer>/.well-known/openid-configuration | ||
* @param issuer used as the base for all other urls | ||
* @returns ValidatedIssuerMetadata | ||
*/ | ||
export const mockOpenIdConfiguration = (issuer = "https://auth.org/"): ValidatedIssuerMetadata => ({ | ||
issuer, | ||
revocation_endpoint: issuer + "revoke", | ||
token_endpoint: issuer + "token", | ||
authorization_endpoint: issuer + "auth", | ||
registration_endpoint: issuer + "registration", | ||
jwks_uri: issuer + "jwks", | ||
response_types_supported: ["code"], | ||
grant_types_supported: ["authorization_code", "refresh_token"], | ||
code_challenge_methods_supported: ["S256"], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.