Skip to content

Lab 7: Model Access & Key Lifecycle

An AI gateway decides which models each application may use and which credentials are still valid. In this lab you verify that a request for a model that is not approved is refused (OWASP LLM03 — Supply Chain), and you manage the life of a virtual key: rotate its secret and revoke a key that is no longer needed.

🎯 Lab Objectives

In this lab, you will:

  • Verify that only approved models can be used through FortiAIGate.
  • Rotate the secret of a virtual key and update the client.
  • Revoke a virtual key and confirm that it no longer works.
  • Find the refused requests in the Traffic Log.

🧭 How Model Access Works

A request is accepted only if the model is allowed at every level:

Level Who controls it In this lab
Organization Instructor llama3.2:3b enabled in Models
Workspace Instructor llama3.2:3b allocated to your workspace
Project You HR-Assist allows llama3.2:3b
Virtual key You hr-chatbot-key granted llama3.2:3b

Any other model name is refused, even if the application asks for it and even if the provider offers it.


1. Approved Models Only

Step 1 – Keep a policy on the key

Make sure POL-UC1-Prompt-Injection is attached to hr-chatbot-key (Edit > Governance) and remove any other lab policy.

Step 2 – Request a model that is not approved

In the ChatBot, set Model to ollama-llama3.1:8b and click Save. Then send:

Prompt:

What is the dress code policy?

Expected result:

  • The request is refused: the model is not allowed for your key.
  • The request never reaches Ollama.
Step 3 – Find the refused request

Navigate to: Logs > Traffic Log and open the request.

Expected result:

  • The entry shows a Request Refused section with the reason.
Step 4 – Restore the approved model

Set the ChatBot Model back to llama3.2-3b, click Save and send a normal prompt to confirm it works.


2. Rotate a Secret

Step 5 – Rotate the ChatBot key

Rotation replaces a secret that may have been exposed, without changing the key's settings, associations or usage.

Navigate to: Virtual Keys > hr-chatbot-key > ⋮ > Rotate.

Copy the new secret now. It is shown only once.

Step 6 – Test the old and the new secret

Send a prompt from the ChatBot without changing its API Key.

Expected result:

  • The request is refused: the old secret stopped working. There is no grace period.

Paste the new secret in the ChatBot API Key field, click Save and send the prompt again.

Expected result:

  • The request is answered with the new secret.

Short delay

Rotation and revocation invalidate the gateway's authentication cache. In rare cases, enforcement can take a few seconds until cached entries expire.


3. Revoke a Key

Step 7 – Create a temporary key

Navigate to: Virtual Keys > Create Virtual Key.

Configure:

  • Project: HR-Assist
  • Key Type: Service
  • Name: hr-temp-key
  • Model Access: llama3.2:3b

Copy the secret, put it in the ChatBot API Key field and send a prompt to confirm it works.

Step 8 – Revoke the temporary key

Navigate to: Virtual Keys > hr-temp-key > ⋮ > Revoke.

  • Reason: Workshop test - application retired

Send a prompt from the ChatBot with hr-temp-key.

Expected result:

  • The request is refused.
  • The key stays in the list as Revoked, with its reason, for audit.

Put the hr-chatbot-key secret back in the ChatBot and click Save.

Revoke is permanent

A revoked key cannot be restored. To stop an application temporarily, use a budget instead (Lab 8).


🏁 Conclusion

In this lab, you:

  • Verified that only approved models can be used.
  • Rotated a secret and updated the client.
  • Revoked a key and confirmed that it no longer works.
  • Found the refused requests in the Traffic Log.

In the next lab you will control consumption and investigate every request in the logs.