For customers who have enabled IAM for OpenFaaS, OIDC can be used to authenticate the CLI. An initial token will be obtained from your Identity Provider (IdP) and then it will be exchanged for an OpenFaaS access token.
You'll need to start off by installing the faas-cli, if you don't have it yet, it's available on GitHub.
Do you want to run faas-cli from a server instead of as a human user?
SSO and OIDC are primarily designed for interactive use by a human user in front of a keyboard, with a web-browser available. If you need to use an OAuth token to authenticate server-to-server, then you you'll need to create a new OAuth client in your IdP, and then use the --client-secret flag with the faas-cli pro auth command.
Only authorized use of the plugin is permitted, so you will need to enable it now.
Next, for customers who have a GitHub organisation, you will need to send the OpenFaaS team an email with the name of the organisation, and make sure you can log into your account.
faas-cliproenable
A browser will open with a device challenge, once completed, the CLI will be enabled.
Does your team not have a GitHub organisation available?
If your organisation does not use GitHub, or you are not a member of its GitHub organisation, there is an alternative approach to enabling the plugin. Email the OpenFaaS team for the details.
A browser will open and you can log in using your IDP.
Following on from that, a JWT will be exchanged for an OpenFaaS access token, and the CLI will be ready to use.
Whenever you want to log in again, you can use the faas-cli pro auth command, and you will not need to add the --client-id flag or --authority flag again, since they will be saved for you.
Then, whenever a browser is launched, it will open on your Windows host, and the result will come back to the WSL environment.
Note for Windows Subsystem for Linux (WSL) users
When authenticating from WSL, the redirect address will be changed from `http://127.0.0.1` to `http://localhost`. Make sure that the address: `http://localhost:31111/oauth/callback` is added as a callback URL for the IdP app for OpenFaaS.