* Refactor OAuth to be less complex.

* Remove oauth as a standalone api.
 * Rename redundant OAuthAuthenticationFilter to OAuthFilter.
 * Make AuthorizationApi more simple by using form semantics.
 * Simplified OAuth by only permitting RS256 and none algos.
This commit is contained in:
Adrian Cole 2014-11-17 19:50:48 -08:00
parent a2bdf0b484
commit 3f9f8df3f1
23 changed files with 43 additions and 47 deletions

View File

@ -34,7 +34,6 @@ import org.jclouds.googlecloud.config.CurrentProject;
import org.jclouds.googlecomputeengine.compute.config.GoogleComputeEngineServiceContextModule;
import org.jclouds.googlecomputeengine.config.GoogleComputeEngineHttpApiModule;
import org.jclouds.googlecomputeengine.config.GoogleComputeEngineParserModule;
import org.jclouds.oauth.v2.config.OAuthAuthenticationModule;
import org.jclouds.oauth.v2.config.OAuthModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;
@ -84,7 +83,6 @@ public class GoogleComputeEngineApiMetadata extends BaseHttpApiMetadata<GoogleCo
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(GoogleComputeEngineHttpApiModule.class)
.add(GoogleComputeEngineParserModule.class)
.add(OAuthAuthenticationModule.class)
.add(OAuthModule.class)
.add(GoogleComputeEngineServiceContextModule.class)
.build());

View File

@ -32,14 +32,14 @@ import org.jclouds.googlecomputeengine.domain.Instance;
import org.jclouds.googlecomputeengine.domain.Network;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Consumes(APPLICATION_JSON)
public interface Resources {

View File

@ -46,7 +46,7 @@ import org.jclouds.http.annotation.ServerError;
import org.jclouds.location.Provider;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.oauth.v2.config.OAuthScopes.ReadOrWriteScopes;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.ConfiguresHttpApi;
@ -116,7 +116,7 @@ public final class GoogleComputeEngineHttpApiModule extends HttpApiModule<Google
static final class UseApiToResolveProjectName implements Function<Credentials, URI> {
@SkipEncoding({ '/', '=' })
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Consumes(APPLICATION_JSON)
interface GetProject {
@Named("Projects:get")

View File

@ -39,7 +39,7 @@ import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
@ -51,7 +51,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/addresses")
@Consumes(APPLICATION_JSON)
public interface AddressApi {

View File

@ -38,7 +38,7 @@ import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
@ -46,7 +46,7 @@ import org.jclouds.rest.annotations.Transform;
import com.google.common.base.Function;
@SkipEncoding({ '/', '=' })
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/aggregated")
@Consumes(APPLICATION_JSON)
public interface AggregatedListApi {

View File

@ -41,7 +41,7 @@ import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPa
import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
@ -53,7 +53,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/disks")
@Consumes(APPLICATION_JSON)
public interface DiskApi {

View File

@ -35,7 +35,7 @@ import org.jclouds.googlecomputeengine.domain.DiskType;
import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding;
@ -44,7 +44,7 @@ import org.jclouds.rest.annotations.Transform;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/diskTypes")
@Consumes(APPLICATION_JSON)
public interface DiskTypeApi {

View File

@ -43,7 +43,7 @@ import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.FirewallOptions;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
@ -57,7 +57,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/firewalls")
@Consumes(APPLICATION_JSON)
public interface FirewallApi {

View File

@ -42,7 +42,7 @@ import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPa
import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticator;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
@ -54,7 +54,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticator.class)
@RequestFilters(OAuthFilter.class)
@Path("/forwardingRules")
@Consumes(APPLICATION_JSON)
public interface ForwardingRuleApi {

View File

@ -42,7 +42,7 @@ import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.HttpHealthCheckCreationOptions;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticator;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PATCH;
@ -55,7 +55,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticator.class)
@RequestFilters(OAuthFilter.class)
@Path("/httpHealthChecks")
@Consumes(APPLICATION_JSON)
public interface HttpHealthCheckApi {

View File

@ -42,7 +42,7 @@ import org.jclouds.googlecomputeengine.internal.BaseArg0ToIteratorOfListPage;
import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.Fallback;
@ -56,7 +56,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Consumes(APPLICATION_JSON)
public interface ImageApi {

View File

@ -44,7 +44,7 @@ import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
@ -57,7 +57,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/instances")
@Consumes(APPLICATION_JSON)
public interface InstanceApi {

View File

@ -35,7 +35,7 @@ import org.jclouds.googlecomputeengine.domain.MachineType;
import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding;
@ -44,7 +44,7 @@ import org.jclouds.rest.annotations.Transform;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/machineTypes")
@Consumes(APPLICATION_JSON)
public interface MachineTypeApi {

View File

@ -39,7 +39,7 @@ import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
@ -51,7 +51,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/networks")
@Consumes(APPLICATION_JSON)
public interface NetworkApi {

View File

@ -40,7 +40,7 @@ import org.jclouds.googlecomputeengine.internal.BaseArg0ToIteratorOfListPage;
import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.Fallback;
@ -51,7 +51,7 @@ import org.jclouds.rest.annotations.Transform;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Consumes(APPLICATION_JSON)
public interface OperationApi {

View File

@ -29,7 +29,7 @@ import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.NullOn400or4
import org.jclouds.googlecomputeengine.domain.Metadata;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.domain.Project;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
@ -37,7 +37,7 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.binders.BindToJsonPayload;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Consumes(APPLICATION_JSON)
public interface ProjectApi {

View File

@ -35,7 +35,7 @@ import org.jclouds.googlecomputeengine.domain.Region;
import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding;
@ -44,7 +44,7 @@ import org.jclouds.rest.annotations.Transform;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/regions")
@Consumes(APPLICATION_JSON)
public interface RegionApi {

View File

@ -42,7 +42,7 @@ import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.options.RouteOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
@ -53,7 +53,7 @@ import org.jclouds.rest.annotations.Transform;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/routes")
@Consumes(APPLICATION_JSON)
public interface RouteApi {

View File

@ -37,7 +37,7 @@ import org.jclouds.googlecomputeengine.domain.Snapshot;
import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding;
@ -46,7 +46,7 @@ import org.jclouds.rest.annotations.Transform;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/snapshots")
@Consumes(APPLICATION_JSON)
public interface SnapshotApi {

View File

@ -45,7 +45,7 @@ import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPa
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticator;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
@ -57,7 +57,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticator.class)
@RequestFilters(OAuthFilter.class)
@Path("/targetPools")
@Consumes(APPLICATION_JSON)
public interface TargetPoolApi {

View File

@ -35,7 +35,7 @@ import org.jclouds.googlecomputeengine.domain.Zone;
import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.oauth.v2.filters.OAuthFilter;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding;
@ -44,7 +44,7 @@ import org.jclouds.rest.annotations.Transform;
import com.google.common.base.Function;
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@RequestFilters(OAuthFilter.class)
@Path("/zones")
@Consumes(APPLICATION_JSON)
public interface ZoneApi {

View File

@ -21,7 +21,6 @@ import static com.google.common.base.Throwables.propagate;
import static com.google.common.io.BaseEncoding.base64Url;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecloud.config.GoogleCloudProperties.PROJECT_NAME;
import static org.jclouds.oauth.v2.JWSAlgorithms.NONE;
import static org.jclouds.oauth.v2.config.OAuthProperties.JWS_ALG;
import static org.jclouds.util.Strings2.toStringAndClose;
@ -80,7 +79,7 @@ public class BaseGoogleComputeEngineExpectTest<T> extends BaseRestApiExpectTest<
Properties props = super.setupProperties();
props.put(PROJECT_NAME, "party");
// use no sig algorithm for expect tests (means no credential is required either)
props.put(JWS_ALG, NONE);
props.put(JWS_ALG, "none");
return props;
}

View File

@ -37,8 +37,7 @@ import java.security.interfaces.RSAPublicKey;
import java.util.concurrent.atomic.AtomicInteger;
import org.jclouds.crypto.Crypto;
import org.jclouds.oauth.v2.functions.BuildTokenRequest;
import org.jclouds.oauth.v2.functions.BuildTokenRequest.TestBuildTokenRequest;
import org.jclouds.oauth.v2.filters.JWTBearerTokenFlow;
import org.jclouds.ssh.SshKeys;
import com.google.common.base.Supplier;
@ -68,7 +67,7 @@ enum GoogleComputeEngineTestModule implements Module {
@Override public void configure(Binder binder) {
// Predictable time
binder.bind(BuildTokenRequest.class).to(TestBuildTokenRequest.class);
binder.bind(JWTBearerTokenFlow.class).to(JWTBearerTokenFlow.TestJWTBearerTokenFlow.class);
// Predictable ssh keys
Crypto crypto = createMock(Crypto.class);