-
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good. But we cannot have GenericJson
exposed in our public API surface. Plus few other nits.
@@ -157,4 +196,14 @@ public void testUpdateRequestMissingIssuer() { | |||
public void testUpdateRequestInvalidIssuerUrl() { | |||
new OidcProviderConfig.UpdateRequest("oidc.provider-id").setIssuer("not a valid url"); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the developer sets responseTypeCode but doesn't specify a client secret? Should the SDK validate that? Let's at least have a test case to exercise that scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm letting the backend deal with it - they will return an error. I can't do this check in update, and if you want me to make this check in create then we'll be forcing the dev to call setClientSecret before calling setCodeResponseType. If you prefer I do that let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my other comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a couple of suggestions.
.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 comment
The 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 AbstractCreateRequest
and AbstractUpdateRequest
classes:
protected void validate() { }
Map<String, Object> getProperties() {
this.validate();
return ImmutableMap.copyOf(properties);
}
Now in OidcProviderConfig.CreateRequest
and OidcProviderConfig.UpdateRequest
:
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.
src/test/java/com/google/firebase/auth/OidcProviderConfigTest.java
Outdated
Show resolved
Hide resolved
@@ -157,4 +196,14 @@ public void testUpdateRequestMissingIssuer() { | |||
public void testUpdateRequestInvalidIssuerUrl() { | |||
new OidcProviderConfig.UpdateRequest("oidc.provider-id").setIssuer("not a valid url"); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my other comment.
This reverts commit 42bb217.
Provides an option for developers to specify the OAuth response type for their OIDC provider (either one of these can be set:):