Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.6.1"),
.package(url: "https://github.com/awslabs/aws-sdk-swift", from: "1.3.50"),
.package(url: "https://github.com/smithy-lang/smithy-swift", from: "0.145.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.3"),
.package(url: "https://github.com/awslabs/aws-crt-swift", from: "0.52.0"),
.package(url: "https://github.com/awslabs/aws-sdk-swift", from: "1.5.16"),
.package(url: "https://github.com/smithy-lang/smithy-swift", from: "0.152.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.4"),
.package(url: "https://github.com/awslabs/aws-crt-swift", from: "0.52.1"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ let bedrock = try await BedrockService(
)
```

As usual, do not store or hardcode API Keys in yoru front end application.
As usual, do not store or hardcode API Keys in your front end application.

### Static Credentials Authentication

Expand Down
2 changes: 1 addition & 1 deletion Sources/BedrockAuthentication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public enum BedrockAuthentication: Sendable, CustomStringConvertible {
case .default, .apiKey(_):
return nil //TODO should we throw an error when apiKey is used ?
case .profile(let profileName):
return try? ProfileAWSCredentialIdentityResolver(profileName: profileName)
return ProfileAWSCredentialIdentityResolver(profileName: profileName)
case .sso(let profileName):
return try? SSOAWSCredentialIdentityResolver(profileName: profileName)
case .webIdentity(let token, let roleARN, let region, let notification):
Expand Down
11 changes: 1 addition & 10 deletions Sources/BedrockService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,9 @@ public struct BedrockService: Sendable {

// support API keys
if case .apiKey(_) = authentication {
// config.httpClientConfiguration.defaultHeaders.add(
// name: "Authorization",
// value: "Bearer \(key)"
// )
if let bearerTokenIdentityresolver = authentication.getBearerTokenIdentityResolver(logger: logger) {
config.bearerTokenIdentityResolver = bearerTokenIdentityresolver

// force utilisation of a bearer token instead of AWS credentials + Signv4
// see https://github.com/awslabs/aws-sdk-swift/blob/15b8951d108968f767f4199a3c011e27ac519d61/Sources/Services/AWSBedrockRuntime/Sources/AWSBedrockRuntime/AuthSchemeResolver.swift#L58
config.authSchemeResolver = DefaultBedrockRuntimeAuthSchemeResolver(authSchemePreference: [
"httpBearerAuth"
])
config.authSchemePreference = ["httpBearerAuth"]
} else {
// TODO: should we throw an error here ?
logger.error(
Expand Down
2 changes: 1 addition & 1 deletion Sources/Protocols/BedrockConfigProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protocol BedrockConfigProtocol {

// support bearer token authentication (for API Keys)
var bearerTokenIdentityResolver: any SmithyIdentity.BearerTokenIdentityResolver { get set }
var authSchemeResolver: SmithyHTTPAuthAPI.AuthSchemeResolver { get set }
var authSchemePreference: [String]? { get set }

// not used at the moment, we use the bearer token instead
//var httpClientConfiguration: ClientRuntime.HttpClientConfiguration { get set }
Expand Down
4 changes: 2 additions & 2 deletions Tests/AuthenticationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ extension BedrockServiceTests {
#expect(token == testApiKey, "Expected token to match the API key")

// check bearer auth scheme
let authScheme = (config.authSchemeResolver as? DefaultBedrockRuntimeAuthSchemeResolver)?.authSchemePreference
#expect(authScheme?.contains("httpBearerAuth") == true, "Expected auth scheme to be HTTP Bearer")
let authSchemePreference = config.authSchemePreference
#expect(authSchemePreference?.contains("httpBearerAuth") == true, "Expected auth scheme to be HTTP Bearer")

}

Expand Down
Loading