目录

Authentication Management

Currently, ohpm-repo supports certificate authentication and AccessToken authentication.

Certificate authentication: When the publish, unpublish, or dist-tags command is executed on the ohpm client, the encrypted SSH certificate is embedded for identity authentication.

AccessToken authentication: Add the access token generated by ohpm-repo to the ohpm client configuration file to implement password-free authentication for operations including publish, unpublish, dist-tags, info, and install.

Certificate Authentication

Before using ohpm to publish packages, you need to set publish_id and key_path in the .ohpmrc configuration file. publish_id indicates the publishing ID, and key_path corresponds to the address of the private key. For details about the publishing process, see Publishing with the CLI Tool. Authentication management is used to manage the public key information corresponding to the private key and verify the information when users use ohpm to publish packages. The following figure shows the Security manage page.

  1. Click Add. The AddPublicKey dialog box is displayed. You can add public key information. A user can add up to ten public-key entries. By configuring multiple distinct public keys, multiple persons can share this user account to publish packages via ohpm. The following figure shows the page effect.

  2. Click AddKeys to view the description of public key generation, as shown in the following figure.

  3. Click Delete to delete the existing public key information, as shown in the following figure.

AccessToken

Access token is a new authentication mechanism introduced in ohpm-repo 2.1.0 (the ohpm CLI tool of 1.6.0 or later is required). You can generate a token on the ohpm-repo page and add it to the configuration file of the ohpm client. When interacting with ohpm-repo, the client automatically attaches a token for identity authentication.

The token has two permission levels: read-only token that allows info and install operations; read-write token that supports publish, unpublish, and dist-tags operations in addition to operations of the read-only permission. A maximum of 10 tokens can be generated for each permission type. When a token is generated for the first time, the system automatically copies it to the clipboard and does not display the complete token content later. The following figure shows the AccessToken page.

  1. Click Generate Read-Only Token, ohpm-repo automatically generates an authentication token dedicated to package information query (info) and package installation (install) operations on the ohpm client, as shown in the following figure.

  2. Click Generate Read-Write Token, ohpm-repo automatically generates an authentication token dedicated to operations including package information query (info), package installation (install), package publishing (publish), package unpublishing (unpublish), and version tagging (dist-tags) on the ohpm client. The following figure shows the page effect.

  3. Click AccessToken Guide. A tutorial is displayed to show you how to effectively use and configure AccessToken. The following figure shows the page effect.

  4. Click Delete to delete the corresponding token. The following figure shows the page effect.

  5. Use of AccessToken:
    1. Generate a token on the ohpm-repo page.
    2. Add the token in the .ohpmrc configuration file of the ohpm client. A configuration example is as follows:
      //127.0.0.1:8088/repos/ohpm/:_auth=readWriteToken
      //127.0.0.1:8088/repos/ohpm/:_read_auth=readOnlyToken

      //127.0.0.1:8088/repos/ohpm/ is the registry value without the protocol name. :_auth and :_read_auth indicate the read-write token and read-only token, respectively. readWriteToken and readOnlyToken indicate the token values. If the ohpm client executes the info and install commands, it preferentially uses read-only tokens over read-write tokens. If the ohpm client executes the publish, unpublish, and dist-tags commands, it uses only read-write tokens. For each type of token, a maximum of three tokens can be configured.