ScmAuth
Home > @backstage/integration-react
> ScmAuth
An implementation of the ScmAuthApi that merges together OAuthApi instances to form a single instance that can handles authentication for multiple providers.
Signature:
class ScmAuth implements ScmAuthApi
Implements: ScmAuthApi
Example
// Supports authentication towards both public GitHub and GHE:
createApiFactory({
api: scmAuthApiRef,
deps: {
gheAuthApi: gheAuthApiRef,
githubAuthApi: githubAuthApiRef,
},
factory: ({ githubAuthApi, gheAuthApi }) =>
ScmAuth.merge(
ScmAuth.forGithub(githubAuthApi),
ScmAuth.forGithub(gheAuthApi, {
host: 'ghe.example.com',
}),
)
})
Methods
Method | Modifiers | Description |
---|---|---|
createDefaultApiFactory() | static | Creates an API factory that enables auth for each of the default SCM providers. |
forAuthApi(authApi, options) | static | Creates a general purpose ScmAuth instance with a custom scope mapping. |
forAzure(microsoftAuthApi, options) | static | Creates a new ScmAuth instance that handles authentication towards Azure. The host option determines which URLs that are handled by this instance and defaults to The default scopes are:
If the additional
|
forBitbucket(bitbucketAuthApi, options) | static | Creates a new ScmAuth instance that handles authentication towards Bitbucket. The host option determines which URLs that are handled by this instance and defaults to The default scopes are:
If the additional
|
forGithub(githubAuthApi, options) | static | Creates a new ScmAuth instance that handles authentication towards GitHub. The host option determines which URLs that are handled by this instance and defaults to The default scopes are:
If the additional
|
forGitlab(gitlabAuthApi, options) | static | Creates a new ScmAuth instance that handles authentication towards GitLab. The host option determines which URLs that are handled by this instance and defaults to The default scopes are:
If the additional
|
getCredentials(options) | Fetches credentials for the given resource. | |
isUrlSupported(url) | Checks whether the implementation is able to provide authentication for the given URL. | |
merge(providers) | static | Merges together multiple ScmAuth instances into one that routes requests to the correct instance based on the URL. |