This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Module : auth

Module Overview

This module provides the default authentication provider configurations, which can be extended to create new authentication providers.

For information on the operations, which you can perform with this module, see the below Objects. For examples on the usage of the operations, see the Secured Service with Basic Auth Example and Secured Client with Basic Auth Example.

Records

BasicAuthConfig

Represents the inbound Basic Authentication configurations.

Credential

Represents the Basic Authentication configurations, which are used by the HTTP endpoint.

Detail

Record type to hold the details of an error.

Objects

InboundAuthProvider

Represents the inbound Auth provider, which could be used to authenticate endpoints.

InboundBasicAuthProvider

Represents the configuration file based inbound Basic Auth provider, which is an implementation of the auth:InboundAuthProvider interface.

OutboundAuthProvider

Represents the outbound Auth provider, which could be used to authenticate external endpoints.

OutboundBasicAuthProvider

Represents the outbound Basic Auth authenticator, which is an implementation of the auth:OutboundAuthProvider interface.

Functions

checkForScopeMatch

Checks whether the scopes of the user match the scopes of the resource.

extractUsernameAndPassword

Extracts the username and the password from the base64-encoded username:password value.

setAuthenticationContext

Sets the authentication-related values (scheme, auth token) to the authentication context of the invocation context.

setPrincipal

Sets the authentication-related values (user ID, username, scopes, claims) to the principal of the invocation context.

Constants

AUTH_ERROR

Represents the Auth error reason.

DEFAULT_CHARSET

Default charset to be used with password hashing.

CONFIG_PREFIX

Prefix used to denote special configuration values.

CONFIG_PREFIX_SHA256

Prefix used to denote that the config value is a SHA-256 hash.

CONFIG_PREFIX_SHA384

Prefix used to denote that the config value is a SHA-384 hash.

CONFIG_PREFIX_SHA512

Prefix used to denote that the config value is a SHA-512 hash.

AUTH_SCHEME_BASIC

Prefix used to denote Basic Authentication scheme.

AUTH_SCHEME_BEARER

The prefix used to denote the Bearer Authentication scheme.

Errors

Error

Represents the Auth error type with details.