r/opencode • • 25d ago

I made OpenCode sign in to my self-hosted LLM with SSO, no more API keys 🎉

Post image

Hey everyone! 👋

My homelab runs llama.cpp and SearXNG behind Keycloak, and my family signs in with their own accounts. OpenCode was the last thing still asking for a static API key, so I fixed that.

opencode-oauth: run /connect, sign in through your identity provider in the browser, and you're in. OpenCode keeps the token fresh, and web search can use the same sign-in. The GIF shows the whole flow.

It should work with any OAuth 2.0 provider (Authentik, Authelia, Pocket ID, Entra ID…), but so far I've only run it with Keycloak. I'd love for you to try it with yours and tell me how it goes, good or bad!

Setup is one plugin entry: https://github.com/kevinpark1217/opencode-oauth

0 Upvotes

5 comments sorted by

2

u/butterfly_labs 25d ago

Why not use a service account?

2

u/kevinpark1217 25d ago

A service account works great for one person or a bot. For a shared LLM it gets awkward:

  • Everyone has the same long-lived secret in their OpenCode config.
  • You can't revoke one person without rotating it for everyone.
  • It skips SSO, so MFA and group-based access don't apply.

With sign-in, each person uses their own account and short-lived tokens that refresh on their own. If it's only you, an API key is totally fine!

1

u/DrySpite5067 23d ago

there is no way u work in ~/tmp no way

1

u/kevinpark1217 22d ago

The GIF is recorded in a throwaway container with a mock sign-in page and a mock model, so it doesn't show my real setup 😄