-
Notifications
You must be signed in to change notification settings - Fork 289
feat: enables OIDC auth code flow #522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1490,7 +1490,10 @@ public void testCreateOidcProvider() throws Exception { | |
.setDisplayName("DISPLAY_NAME") | ||
.setEnabled(true) | ||
.setClientId("CLIENT_ID") | ||
.setIssuer("https://oidc.com/issuer"); | ||
.setClientSecret("CLIENT_SECRET") | ||
.setIssuer("https://oidc.com/issuer") | ||
.setCodeResponseType(true) | ||
.setIdTokenResponseType(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the Node.js SDK we are adding checks to make sure that exactly one is true, when both code and idToken response types are specified. If we want we can do something similar here too. But it will probably require some additional changes. In the protected void validate() { }
Map<String, Object> getProperties() {
this.validate();
return ImmutableMap.copyOf(properties);
} Now in private static void validateResponseTypes(Map<String, Object> properties) {
// Check if clientSecret is set when code = true
// Check that when both code and idToken are specified, they are not both true or both false
}
@Override
protected void validate() {
validateResponseTypes(this.properties);
} Take it as a suggestion. I think for the initial release, the way it's implemented now is probably fine. |
||
|
||
OidcProviderConfig config = FirebaseAuth.getInstance().createOidcProviderConfig(createRequest); | ||
|
||
|
@@ -1501,7 +1504,13 @@ public void testCreateOidcProvider() throws Exception { | |
assertEquals("DISPLAY_NAME", parsed.get("displayName")); | ||
assertTrue((boolean) parsed.get("enabled")); | ||
assertEquals("CLIENT_ID", parsed.get("clientId")); | ||
assertEquals("CLIENT_SECRET", parsed.get("clientSecret")); | ||
assertEquals("https://oidc.com/issuer", parsed.get("issuer")); | ||
|
||
Map<String, Boolean> responseType = (Map<String, Boolean>) parsed.get("responseType"); | ||
assertTrue(responseType.get("code")); | ||
assertTrue(responseType.get("idToken")); | ||
|
||
GenericUrl url = interceptor.getResponse().getRequest().getUrl(); | ||
assertEquals("oidc.provider-id", url.getFirst("oauthIdpConfigId")); | ||
} | ||
|
@@ -1515,9 +1524,12 @@ public void testCreateOidcProviderAsync() throws Exception { | |
.setDisplayName("DISPLAY_NAME") | ||
.setEnabled(true) | ||
.setClientId("CLIENT_ID") | ||
.setIssuer("https://oidc.com/issuer"); | ||
.setClientSecret("CLIENT_SECRET") | ||
.setIssuer("https://oidc.com/issuer") | ||
.setCodeResponseType(true) | ||
.setIdTokenResponseType(true); | ||
|
||
OidcProviderConfig config = | ||
OidcProviderConfig config = | ||
FirebaseAuth.getInstance().createOidcProviderConfigAsync(createRequest).get(); | ||
|
||
checkOidcProviderConfig(config, "oidc.provider-id"); | ||
|
@@ -1527,7 +1539,13 @@ public void testCreateOidcProviderAsync() throws Exception { | |
assertEquals("DISPLAY_NAME", parsed.get("displayName")); | ||
assertTrue((boolean) parsed.get("enabled")); | ||
assertEquals("CLIENT_ID", parsed.get("clientId")); | ||
assertEquals("CLIENT_SECRET", parsed.get("clientSecret")); | ||
assertEquals("https://oidc.com/issuer", parsed.get("issuer")); | ||
|
||
Map<String, Boolean> responseType = (Map<String, Boolean>) parsed.get("responseType"); | ||
assertTrue(responseType.get("code")); | ||
assertTrue(responseType.get("idToken")); | ||
|
||
GenericUrl url = interceptor.getResponse().getRequest().getUrl(); | ||
assertEquals("oidc.provider-id", url.getFirst("oauthIdpConfigId")); | ||
} | ||
|
@@ -1730,7 +1748,10 @@ public void testTenantAwareUpdateOidcProvider() throws Exception { | |
.setDisplayName("DISPLAY_NAME") | ||
.setEnabled(true) | ||
.setClientId("CLIENT_ID") | ||
.setIssuer("https://oidc.com/issuer"); | ||
.setClientSecret("CLIENT_SECRET") | ||
.setIssuer("https://oidc.com/issuer") | ||
.setCodeResponseType(true) | ||
.setIdTokenResponseType(true); | ||
|
||
OidcProviderConfig config = tenantAwareAuth.updateOidcProviderConfig(request); | ||
|
||
|
@@ -1739,12 +1760,18 @@ public void testTenantAwareUpdateOidcProvider() throws Exception { | |
String expectedUrl = TENANTS_BASE_URL + "/TENANT_ID/oauthIdpConfigs/oidc.provider-id"; | ||
checkUrl(interceptor, "PATCH", expectedUrl); | ||
GenericUrl url = interceptor.getResponse().getRequest().getUrl(); | ||
assertEquals("clientId,displayName,enabled,issuer", url.getFirst("updateMask")); | ||
assertEquals("clientId,clientSecret,displayName,enabled,issuer,responseType.code," | ||
+ "responseType.idToken", url.getFirst("updateMask")); | ||
GenericJson parsed = parseRequestContent(interceptor); | ||
assertEquals("DISPLAY_NAME", parsed.get("displayName")); | ||
assertTrue((boolean) parsed.get("enabled")); | ||
assertEquals("CLIENT_ID", parsed.get("clientId")); | ||
assertEquals("CLIENT_SECRET", parsed.get("clientSecret")); | ||
assertEquals("https://oidc.com/issuer", parsed.get("issuer")); | ||
|
||
Map<String, Boolean> responseType = (Map<String, Boolean>) parsed.get("responseType"); | ||
assertTrue(responseType.get("code")); | ||
assertTrue(responseType.get("idToken")); | ||
} | ||
|
||
@Test | ||
|
@@ -2792,7 +2819,12 @@ private static void checkOidcProviderConfig(OidcProviderConfig config, String pr | |
assertEquals("DISPLAY_NAME", config.getDisplayName()); | ||
assertTrue(config.isEnabled()); | ||
assertEquals("CLIENT_ID", config.getClientId()); | ||
assertEquals("CLIENT_SECRET", config.getClientSecret()); | ||
assertEquals("https://oidc.com/issuer", config.getIssuer()); | ||
|
||
GenericJson responseType = config.getResponseType(); | ||
assertTrue((boolean) responseType.get("code")); | ||
assertFalse((boolean) responseType.get("idToken")); | ||
} | ||
|
||
private static void checkSamlProviderConfig(SamlProviderConfig config, String providerId) { | ||
|
@@ -2824,5 +2856,4 @@ private static void checkUrl(TestResponseInterceptor interceptor, String method, | |
private interface UserManagerOp { | ||
void call(FirebaseAuth auth) throws Exception; | ||
} | ||
|
||
} |
Uh oh!
There was an error while loading. Please reload this page.