2017-03-17 6 views
1

APIでオーソ定義:リファレンス私はcloudformationテンプレートでカスタム承認者を定義したゲートウェイ・パス

MyCustomAuthorizer: 
    Type: AWS::ApiGateway::Authorizer 
    Properties: 
    Name: "MyCustomAuthorizer" 
    Type: "TOKEN" 
    AuthorizerUri: "arn:my_lambda" 
    IdentitySource: "method.request.header.Auth" 
    RestApiId: 
     Ref: ApiGatewayApi 

そして私は、APIゲートウェイAPIがあります。私が作るにはどうすればよい

ApiGatewayApi: 
    Type: AWS::ApiGateway::RestApi 
    Properties: 
     Name: "ApiGatewayApi" 
     Description: "Api gateway REST API" 
     Body: 
     basePath: "/prod" 
     schemes: 
     - "https" 
     paths: 
      /echo: 
      get: 
       consumes: 
       - "application/json" 
       produces: 
       - "application/json" 
       responses: 
       "200": 
        description: "200 response" 
        schema: 
        $ref: "#/definitions/schema" 
       security: 
       - sigv4: [] 

を具体的には/echoパスの使用MyCustomAuthorizer

私はドキュメントがexampleを持って指示here

答えて

0

を使用して、コンソール上でこれを行うことができます。方法の範囲内で「セキュリティ」プロパティにカスタム許可を追加する必要があります

"securityDefinitions" : { 
    "test-authorizer" : { 
     "type" : "apiKey",       // Required and the value must be "apiKey" for an API Gateway API. 
     "name" : "Authorization",     // The source header name identifying this authorizer. 
     "in" : "header",       // Required and the value must be "header" for an AAPI Gateway API. 
     "x-amazon-apigateway-authtype" : "oauth2", // Specifies the authorization mechanism for the client. 
     "x-amazon-apigateway-authorizer" : {  // An API Gateway custom authorizer definition 
     "type" : "token",      // Required property and the value must "token" 
     "authorizerUri" : "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:account-id:function:function-name/invocations", 
     "authorizerCredentials" : "arn:aws:iam::account-id:role", 
     "identityValidationExpression" : "^x-[a-z]+", 
     "authorizerResultTtlInSeconds" : 60 
     } 
    } 
    } 


    "/http" : { 
    "get" : { 
    "responses" : { }, 
    "security" : [ { 
     "test-authorizer" : [ ] 
    } ], 
    "x-amazon-apigateway-integration" : { 
     "type" : "http", 
     "responses" : { 
     "default" : { 
      "statusCode" : "200" 
     } 
     }, 
     "httpMethod" : "GET", 
     "uri" : "http://api.example.com" 
    } 
    } 
} 
関連する問題