Secure APIs Flashcards

(14 cards)

1
Q

What is the most common way to secure APIs?

A
  • Using subscription key
  • devs who need to consume the published API must include a valid subscription key in the HTTP requests when they make calls to those APIs
  • APIM gateway rejects calls without a sub key and calls arent forwarded to backend services
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a subscription in APIM?

A
  • Required for a sub key
  • a named container for a pair of sub keys
  • devs who need to consume API can get subs, they dont need approval from API publishers
  • Publishers can also create subs directly for consumers
  • has a primary and secondary key which avoids downtime when needing to regen keys
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What us a subscription key?

A
  • unique auto generated key that can be passed through in headers of a client requests or as a query string param
  • key linked to sub which can be scoped to different areas
  • scopes are all APIs, single API or product
  • Apps that call protected APIs must have a key in each request
  • Can regen keys at any time e.g. if we suspect one has been shared with unauth user
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do subscriptions work with products?

A
  • for products where subs are enabled clients must supply a key when making calls to APIs in that product
  • devs can obtain a key by submitting a sub request
  • if request is approved the key must be sent to them in secure format
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is header name and query string for sub key?

A

Ocp-Apim-Subscription-key and subscription-key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can I test out API calls?

A
  • dev portal or CLI tools such as CURL

Curl –header “Ocp-Apim-Subscription-key: <key>" https://<apim>.azure-api.net/api/path</apim></key>

or

Curl https://<apim>.azure-api.net/api/path?subscription-key=<key></key></apim>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are certs in APIM?

A
  • can be used to provides TLS mutual auth between the client and the API gateway
  • can configure the APIM gateway to allow only requests with certs containing a specific thumbprint
  • handled through inbound policies
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What can APIM gateway check for to ensure security?

A
  • certificate authority
  • thumbprint
  • subject
  • expiration date
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can we verify a cert?

A
  • certs are signed to ensure they arent tampered with
  • check who issues cert
  • if the cert is issued by a partner verify that it came from them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the APIM consumption tier and how does it relate to certs?

A
  • designed to conform with serverless design principles such as Azure functions
  • must explicitly enable the use of client certs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can we check thumbprint or client cert? What would the policy statement look like?

A
  • ensures that the values in the cert havent been altered since the cert was issued

<choose>
<when condition="@(context.Request.Certificate == null || context.Request.Certificate.Thumbprint != "desired-thumbprint")" >
<return-response> <set-status></set-status></return-response>
</when>
</choose>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can we check thumbprint against certs uploaded to APIM? What would the policy statement look like?

A
  • usually each customer or partner company would pass a different cert with a different thumbprint
  • obtain the certs from your partners and use the client certificates page in the portal to upload them to APIM
  • Can then use the following…

<when>
</when>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can we check the issuer and subject of a client cert?

A

<when condition=”@(context.Request.Certificate == null || context.Request.Certificate.Issuer != “trusted-issuer” || context.Request.Certificate.SubjectName.Name != “expected-subject-name”)” >

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Command to create APIM?

A

az apim create

How well did you know this?
1
Not at all
2
3
4
5
Perfectly