

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

# HttpApiFunctionAuth
<a name="sam-property-function-httpapifunctionauth"></a>

Konfiguriert die Autorisierung auf Veranstaltungsebene.

Konfigurieren Sie Auth für eine bestimmte API \$1 Path \$1 Methode

## Syntax
<a name="sam-property-function-httpapifunctionauth-syntax"></a>

Verwenden Sie die folgende Syntax, um diese Entität in Ihrer AWS Serverless Application Model (AWS SAM) -Vorlage zu deklarieren.

### YAML
<a name="sam-property-function-httpapifunctionauth-syntax.yaml"></a>

```
  [AuthorizationScopes](#sam-function-httpapifunctionauth-authorizationscopes): List
  [Authorizer](#sam-function-httpapifunctionauth-authorizer): String
```

## Eigenschaften
<a name="sam-property-function-httpapifunctionauth-properties"></a>

 `AuthorizationScopes`   <a name="sam-function-httpapifunctionauth-authorizationscopes"></a>
Die Autorisierungsbereiche, die für diese API, diesen Pfad und diese Methode gelten sollen.  
Die hier aufgelisteten Bereiche setzen alle Bereiche außer Kraft, die von angewendet werden, `DefaultAuthorizer` falls vorhanden.  
*Typ*: Liste  
*Required*: No  
*CloudFormation Kompatibilität*: Diese Eigenschaft ist einzigartig für AWS SAM und hat kein CloudFormation Äquivalent.

 `Authorizer`   <a name="sam-function-httpapifunctionauth-authorizer"></a>
Die `Authorizer` für eine bestimmte Funktion. Um die IAM-Autorisierung zu verwenden, geben Sie `EnableIamAuthorizer` im `Globals` Abschnitt Ihrer Vorlage die Angabe `AWS_IAM` und Spezifizierung `true` für an.  
Wenn Sie in der API einen Global Authorizer angegeben haben und eine bestimmte Funktion öffentlich machen möchten, überschreiben Sie dies, indem Sie auf setzen`Authorizer`. `NONE`  
*Typ:* Zeichenfolge  
*Required*: No  
*CloudFormation Kompatibilität*: Diese Eigenschaft ist einzigartig für AWS SAM und hat kein CloudFormation Äquivalent.

## Beispiele
<a name="sam-property-function-httpapifunctionauth--examples"></a>

### Funktions-Auth
<a name="sam-property-function-httpapifunctionauth--examples--function-auth"></a>

Autorisierung auf Funktionsebene angeben

#### YAML
<a name="sam-property-function-httpapifunctionauth--examples--function-auth--yaml"></a>

```
Auth:
  Authorizer: OpenIdAuth
  AuthorizationScopes:
    - scope1
    - scope2
```

### IAM-Autorisierung
<a name="sam-property-function-httpapifunctionauth--examples--iam-authorization"></a>

Gibt die IAM-Autorisierung auf Ereignisebene an. Um die `AWS_IAM` Autorisierung auf Veranstaltungsebene zu verwenden, müssen Sie `EnableIamAuthorizer` im `Globals` Abschnitt Ihrer Vorlage auch `true` for angeben. Weitere Informationen finden Sie unter [Abschnitt „Globals“ der Vorlage AWS SAM](sam-specification-template-anatomy-globals.md).

#### YAML
<a name="sam-property-function-httpapifunctionauth--examples--iam-authorization--yaml"></a>

```
Globals:
  HttpApi:
    Auth:
      EnableIamAuthorizer: true

Resources:
  HttpApiFunctionWithIamAuth:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        ApiEvent:
          Type: HttpApi
          Properties:
            Path: /iam-auth
            Method: GET
            Auth:
              Authorizer: AWS_IAM
      Handler: index.handler
      InlineCode: |
        def handler(event, context):
          return {'body': 'HttpApiFunctionWithIamAuth', 'statusCode': 200}
      Runtime: python3.9
```