Skip to content

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

Merged
merged 5 commits into from
Apr 16, 2021
Merged

feat: enables OIDC auth code flow #522

merged 5 commits into from
Apr 16, 2021

Conversation

lsirac
Copy link
Contributor

@lsirac lsirac commented Apr 6, 2021

Provides an option for developers to specify the OAuth response type for their OIDC provider (either one of these can be set:):

  • id_token
  • code (if set, must also set the client secret)

Copy link
Contributor

@hiranya911 hiranya911 left a 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");
}

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment.

Copy link
Contributor

@hiranya911 hiranya911 left a 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);
Copy link
Contributor

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.

@@ -157,4 +196,14 @@ public void testUpdateRequestMissingIssuer() {
public void testUpdateRequestInvalidIssuerUrl() {
new OidcProviderConfig.UpdateRequest("oidc.provider-id").setIssuer("not a valid url");
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment.

@lsirac lsirac merged commit 42bb217 into master Apr 16, 2021
hiranya911 added a commit that referenced this pull request Apr 21, 2021
hiranya911 added a commit that referenced this pull request Apr 21, 2021
@lsirac lsirac requested review from egilmorez and removed request for egilmorez April 27, 2021 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants