Skip to content
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

Move dest oauth to micronaut #20318

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b42d814
tmp
benmoriceau Nov 23, 2022
5da2868
Fix build
benmoriceau Nov 28, 2022
83c3edc
tmp
benmoriceau Nov 28, 2022
27ccea0
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Nov 28, 2022
e3323ee
Tmp
benmoriceau Nov 29, 2022
648494e
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Nov 30, 2022
9f4fee5
tmp
benmoriceau Dec 1, 2022
2391852
tmp
benmoriceau Dec 1, 2022
453f2fd
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 5, 2022
9032d55
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 5, 2022
212dd86
Tmp
benmoriceau Dec 5, 2022
8fd0939
tmp
benmoriceau Dec 6, 2022
d378aab
tmp
benmoriceau Dec 6, 2022
0ff5a15
Clean up
benmoriceau Dec 6, 2022
8dcef2e
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 7, 2022
4ad415e
tmp
benmoriceau Dec 7, 2022
58d51db
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 7, 2022
c982867
Convert Connection Api Controller
benmoriceau Dec 7, 2022
8de361a
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 7, 2022
fccb967
PR Comments
benmoriceau Dec 8, 2022
e0730b3
convert openapiapicontroller to micronaut (#20258)
colesnodgrass Dec 8, 2022
df5a30e
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 8, 2022
0024dff
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 8, 2022
4d8d7c2
Fix build
benmoriceau Dec 8, 2022
abbf357
Format
benmoriceau Dec 8, 2022
c053aa7
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 9, 2022
7490f23
Remove media type
benmoriceau Dec 9, 2022
556e7d3
Format
benmoriceau Dec 9, 2022
e0dff31
Move dest oauth to micronaut
benmoriceau Dec 9, 2022
9ced4a9
Pr comments
benmoriceau Dec 9, 2022
4314426
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 9, 2022
bb8eb29
format
benmoriceau Dec 9, 2022
50d9670
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions airbyte-proxy/nginx-auth.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ http {
}
}

location ~ ^/api/v1/(connections|destinations|destination_definitions|operations|state)/.* {
location ~ ^/api/v1/(connections|destinations|destination_definitions|destination_oauths|operations|state)/.* {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down Expand Up @@ -93,7 +93,7 @@ http {
}
}

location ~ ^/api/v1/(connections|destinations|destination_definitions|operations|state)/.* {
location ~ ^/api/v1/(connections|destinations|destination_definitions|destination_oauths|operations|state)/.* {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
4 changes: 2 additions & 2 deletions airbyte-proxy/nginx-no-auth.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ http {
proxy_pass "${PROXY_PASS_MICRONAUT_API}";
}

location ~ ^/api/v1/(connections|destinations|destination_definitions|operations|state)/.* {
location ~ ^/api/v1/(connections|destinations|destination_definitions|destination_oauths|operations|state)/.* {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down Expand Up @@ -48,7 +48,7 @@ http {
proxy_pass "${PROXY_PASS_MICRONAUT_API}";
}

location ~ ^/api/v1/(connections|destinations|destination_definitions|operations|state)/.* {
location ~ ^/api/v1/(connections|destinations|destination_definitions|destination_oauths|operations|state)/.* {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.airbyte.db.Database;
import io.airbyte.persistence.job.JobPersistence;
import io.airbyte.server.apis.DestinationDefinitionSpecificationApiController;
import io.airbyte.server.apis.DestinationOauthApiController;
import io.airbyte.server.apis.JobsApiController;
import io.airbyte.server.apis.LogsApiController;
import io.airbyte.server.apis.NotificationsApiController;
Expand All @@ -28,7 +27,6 @@
import io.airbyte.server.apis.WebBackendApiController;
import io.airbyte.server.apis.WorkspaceApiController;
import io.airbyte.server.apis.binders.DestinationDefinitionSpecificationApiBinder;
import io.airbyte.server.apis.binders.DestinationOauthApiBinder;
import io.airbyte.server.apis.binders.JobsApiBinder;
import io.airbyte.server.apis.binders.LogsApiBinder;
import io.airbyte.server.apis.binders.NotificationApiBinder;
Expand All @@ -40,7 +38,6 @@
import io.airbyte.server.apis.binders.WebBackendApiBinder;
import io.airbyte.server.apis.binders.WorkspaceApiBinder;
import io.airbyte.server.apis.factories.DestinationDefinitionSpecificationApiFactory;
import io.airbyte.server.apis.factories.DestinationOauthApiFactory;
import io.airbyte.server.apis.factories.JobsApiFactory;
import io.airbyte.server.apis.factories.LogsApiFactory;
import io.airbyte.server.apis.factories.NotificationsApiFactory;
Expand Down Expand Up @@ -150,8 +147,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

DestinationDefinitionSpecificationApiFactory.setValues(schedulerHandler);

DestinationOauthApiFactory.setValues(oAuthHandler);

SourceOauthApiFactory.setValues(oAuthHandler);

JobsApiFactory.setValues(jobHistoryHandler, schedulerHandler);
Expand All @@ -175,7 +170,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
// server configuration
final Set<Class<?>> componentClasses = Set.of(
DestinationDefinitionSpecificationApiController.class,
DestinationOauthApiController.class,
JobsApiController.class,
LogsApiController.class,
NotificationsApiController.class,
Expand All @@ -191,7 +185,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

final Set<Object> components = Set.of(
new DestinationDefinitionSpecificationApiBinder(),
new DestinationOauthApiBinder(),
new JobsApiBinder(),
new LogsApiBinder(),
new NotificationApiBinder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,34 @@
import io.airbyte.api.model.generated.OAuthConsentRead;
import io.airbyte.api.model.generated.SetInstancewideDestinationOauthParamsRequestBody;
import io.airbyte.server.handlers.OAuthHandler;
import io.micronaut.context.annotation.Context;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Post;
import java.util.Map;
import javax.ws.rs.Path;
import lombok.AllArgsConstructor;

@Path("/v1/destination_oauths")
@AllArgsConstructor
@Controller("/api/v1/destination_oauths")
@Context
Copy link
Member

Choose a reason for hiding this comment

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

Is @Context necessary here? Per the docs WARNING: This annotation should be used sparingly as Micronaut is designed in such a way as to encourage minimal bean creation during startup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@colesnodgrass While testing, I have observed that the first call to the API are longer than the others because of bean initialization. I made the bean to have an eager initialization.

public class DestinationOauthApiController implements DestinationOauthApi {

private final OAuthHandler oAuthHandler;

public DestinationOauthApiController(final OAuthHandler oAuthHandler) {
this.oAuthHandler = oAuthHandler;
}

@Post("/complete_oauth")
@Override
public Map<String, Object> completeDestinationOAuth(final CompleteDestinationOAuthRequest completeDestinationOAuthRequest) {
return ApiHelper.execute(() -> oAuthHandler.completeDestinationOAuth(completeDestinationOAuthRequest));
}

@Post("/get_consent_url")
@Override
public OAuthConsentRead getDestinationOAuthConsent(final DestinationOauthConsentRequest destinationOauthConsentRequest) {
return ApiHelper.execute(() -> oAuthHandler.getDestinationOAuthConsent(destinationOauthConsentRequest));
}

@Post("/oauth_params/create")
@Override
public void setInstancewideDestinationOauthParams(final SetInstancewideDestinationOauthParamsRequestBody setInstancewideDestinationOauthParamsRequestBody) {
ApiHelper.execute(() -> {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.micronaut.core.util.StringUtils;
import jakarta.inject.Named;
import jakarta.inject.Singleton;
import java.net.http.HttpClient;
import java.nio.file.Path;
import java.util.Locale;
import java.util.UUID;
Expand Down Expand Up @@ -86,6 +87,11 @@ public Path workspaceRoot(@Value("${airbyte.workspace.root}") final String works
return Path.of(workspaceRoot);
}

@Singleton
public HttpClient httpClient() {
return HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1).build();
}

@Singleton
public JsonSecretsProcessor jsonSecretsProcessor(final FeatureFlags featureFlags) {
return JsonSecretsProcessor.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import io.airbyte.protocol.models.ConnectorSpecification;
import io.airbyte.server.handlers.helpers.OAuthPathExtractor;
import io.airbyte.validation.json.JsonValidationException;
import jakarta.inject.Singleton;
import java.io.IOException;
import java.net.http.HttpClient;
import java.util.HashMap;
Expand All @@ -48,6 +49,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Singleton
public class OAuthHandler {

private static final Logger LOGGER = LoggerFactory.getLogger(OAuthHandler.class);
Expand Down