Skip to content

Commit c9f5e8e

Browse files
committed
authorization header conveniences
1 parent 167a63e commit c9f5e8e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Sources/AuthProvider/Helper.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ public final class Helper {
1414
// from the request.
1515
public var header: AuthorizationHeader? {
1616
guard let authorization = request?.headers["Authorization"] else {
17-
return nil
17+
guard let query = request?.query else {
18+
return nil
19+
}
20+
21+
if let bearer = query["_authorizationBearer"]?.string {
22+
return AuthorizationHeader(string: "Bearer \(bearer)")
23+
} else if let basic = query["_authorizationBasic"]?.string {
24+
return AuthorizationHeader(string: "Basic \(basic)")
25+
} else {
26+
return nil
27+
}
1828
}
1929

2030
return AuthorizationHeader(string: authorization)

0 commit comments

Comments
 (0)