Class BasicAuthorizationHeaderBuilder
- Namespace
- Cuemon.AspNetCore.Authentication.Basic
- Assembly
- Cuemon.AspNetCore.Authentication.dll
Provides a way to fluently represent a HTTP Basic Authentication header.
public class BasicAuthorizationHeaderBuilder : AuthorizationHeaderBuilder<BasicAuthorizationHeader, BasicAuthorizationHeaderBuilder>
- Inheritance
-
BasicAuthorizationHeaderBuilder
- Inherited Members
Examples
The following example demonstrates how to build a Basic Authorization header value using BasicAuthorizationHeaderBuilder.
using Cuemon.AspNetCore.Authentication.Basic;
namespace MyApp.Examples;
public class BasicAuthorizationHeaderBuilderExample
{
public void Demonstrate()
{
var builder = new BasicAuthorizationHeaderBuilder();
builder.AddUserName("alice");
builder.AddPassword("password");
var headerValue = builder.Build(); // "Basic YWxpY2U6cGFzc3dvcmQ="
}
}
Constructors
BasicAuthorizationHeaderBuilder()
Initializes a new instance of the BasicAuthorizationHeaderBuilder class.
public BasicAuthorizationHeaderBuilder()
Methods
AddPassword(string)
Adds the client identifier that is the public key of the signing process.
public BasicAuthorizationHeaderBuilder AddPassword(string password)
Parameters
passwordstringThe client identifier that is the public key of the signing process.
Returns
- BasicAuthorizationHeaderBuilder
An BasicAuthorizationHeaderBuilder that can be used to further build the HTTP HMAC Authentication header.
AddUserName(string)
Adds the credential scope that defines the remote resource.
public BasicAuthorizationHeaderBuilder AddUserName(string username)
Parameters
usernamestringThe credential scope that defines the remote resource.
Returns
- BasicAuthorizationHeaderBuilder
An BasicAuthorizationHeaderBuilder that can be used to further build the HTTP HMAC Authentication header.
Build()
Builds an instance of BasicAuthorizationHeader that implements AuthorizationHeader.
public override BasicAuthorizationHeader Build()
Returns
- BasicAuthorizationHeader
An instance of BasicAuthorizationHeader.