Fork of n4bb12/verdaccio-oidc-ui
An OpenID Connect Plugin for Verdaccio β https://www.verdaccio.org
This is a Verdaccio plugin that offers OpenID Connect integration for both the browser and the command line.
- UI integration with fully functional login and logout. When clicking the login button the user is redirected to identity provider and returns with a working session.
- Updated usage info and working copy-to-clipboard for setup commands.
- A small CLI for quick-and-easy configuration.
- Verdaccio 3 and 4
- Node >=10
- Chrome, Firefox, Firefox ESR, Edge, Safari, IE 11
$ npm install verdaccio-oidc-ui
- Create an OpenID Connect app at your provider of choice, like https://docs.gitlab.com/ee/integration/openid_connect_provider.html
- The callback URL should be
YOUR_REGISTRY_URL/-/oauth/callback
Merge the below options with your existing Verdaccio config:
middlewares:
oidc-ui:
enabled: true
auth:
oidc-ui:
org: REQUIRED_GROUP
client-id: OIDC_CLIENT_ID
client-secret: OIDC_CLIENT_SECRET
oidc-issuer-url: https://gitlab.com
oidc-username-property: nickname
oidc-groups-property: groups
url_prefix: YOUR_REGISTRY_URL
- The configured values can either be the actual value or the name of an environment variable that contains the value.
- The config props can be specified under either the
middlewares
or theauth
node. Just make sure, the addon is included under both nodes.
Users within this group will be able to authenticate.
These values can be obtained from GitHub OAuth app page at https://github.com/settings/developers.
The URL of your identity provider. If using gitlab.com, it would be https://gitlab.com
The userinfo key that represents a username with your identity provider. Defaults to nickname
See https://docs.gitlab.com/ee/integration/openid_connect_provider.html#shared-information
The userinfo key that represents groups with your identity provider. Defaults to groups
See https://docs.gitlab.com/ee/integration/openid_connect_provider.html#shared-information
If configured, it must match YOUR_REGISTRY_URL
. See GitHub Config.
If you are behind a proxy server, the plugin needs to know the proxy server in order to make GitHub requests.
Configure the below environment variable.
$ export GLOBAL_AGENT_HTTP_PROXY=http://127.0.0.1:8080
See the global-agent docs for detailed configuration instrcutions.
- Click the login button and get redirected to GitHub.
- Authorize the registry for your user and the configured GitHub org - this only needs to be done once.
- When completed, you'll be redirected back to the Verdaccio registry.
You are now logged in.
Important: Make sure to click the Request or Grant button for read:org
access when prompted to authorize.
If you accidentally skipped this step, go to https://github.com/settings/applications, find the Verdaccio registry and grant read:org
access from there.
The easiest way to configure npm is to use this short command:
$ npx verdaccio-oidc-ui --registry http://localhost:4873
- Verdaccio 4:
Open the "Register Info" dialog and klick "Copy to clipboard":
- Verdaccio 3:
Select the text in the header and copy it. In case the text is too long, you can double-click it. The invisible part will still be selected and copied.
- Run the copied commands on your terminal:
$ npm config set //localhost:4873:_authToken "SECRET_TOKEN"
$ npm config set //localhost:4873:always-auth true
- Verify npm is set up correctly by running the
whoami
command. Example:
$ npm whoami --registry http://localhost:4873
n4bb12
If you see your GitHub username, you are ready to start installing and publishing packages.
Click the Logout button as per usual.
Unless OAuth access is revoked in the GitHub settings, the token is valid indefinitely.
To invalidate your active login tokens you need to revoke access on the GitHub OAuth app:
- Go to https://github.com/settings/applications
- Find your Verdaccio app
- Click the Revoke button as shown below
If you have created the GitHub OAuth app, you can also revoke access for all users:
- Go to https://github.com/settings/applications
- Find your Verdaccio app
- Click the app name
- On the app detail page click the Revoke all user tokens button