0
0
Microservicessystem_design~10 mins

Service-to-service authentication in Microservices - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the authentication method used between microservices.

Microservices
auth_method = "[1]"
Drag options to blanks, or click blank then click option'
AOAuth2
BBasicAuth
CNone
DAPIKey
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing BasicAuth which is less secure for service-to-service communication.
Using None which means no authentication.
2fill in blank
medium

Complete the code to define the token type used in service authentication.

Microservices
token_type = "[1]"
Drag options to blanks, or click blank then click option'
ADigest
BBasic
CBearer
DMAC
Attempts:
3 left
💡 Hint
Common Mistakes
Using Basic which is for username-password authentication.
Using Digest or MAC which are less common in microservices.
3fill in blank
hard

Fix the error in the code to correctly validate the token expiration time.

Microservices
if current_time > token.[1]:
Drag options to blanks, or click blank then click option'
Aissued_at
Bexpires_at
Cvalid_until
Dcreated_at
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'issued_at' which is when the token was created, not expiration.
Using 'valid_until' which is not a standard field.
4fill in blank
hard

Fill both blanks to complete the token validation logic.

Microservices
if token.[1] and token.[2] == True:
Drag options to blanks, or click blank then click option'
Ais_active
Bis_valid
Cis_expired
Dis_revoked
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'is_expired' which should be False for valid tokens.
Using 'is_revoked' which should be False for valid tokens.
5fill in blank
hard

Fill all three blanks to complete the service-to-service authentication flow.

Microservices
token = auth_server.get_token(client_id=[1], client_secret=[2])
headers = {"Authorization": "[3] " + token}
response = service.call_api(headers=headers)
Drag options to blanks, or click blank then click option'
A"my_client_id"
B"my_client_secret"
CBearer
DBasic
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Basic' instead of 'Bearer' in the header.
Mixing client ID and secret values.