Credentials

is one RFC 7235 §2.1 credentials or challenge: an authentication scheme followed by either a token68 (token, e.g. the base64 blob of a Basic credential) or a list of auth-params. Both productions have the same grammar, so this one type models the Authorization and the WWW-Authenticate side alike.

scheme is kept as written and compared case-insensitively. Param names are lower-cased and their values unquoted; params holds them in header order.

copy

instantiate

(Fn [(Ref Credentials a)] Credentials)

copies a Credentials.

delete

instantiate

(Fn [Credentials] ())

deletes a Credentials. Should usually not be called manually.

init

instantiate

(Fn [String, String, (Array (Pair String String))] Credentials)

creates a Credentials.

param

defn

(Fn [(Ref Credentials a), (Ref String b)] (Maybe String))

                        (param c name)
                    

looks up auth-param name (case-insensitive), returning (Maybe String).

params

instantiate

(Fn [(Ref Credentials a)] (Ref (Array (Pair String String)) a))

gets the params property of a Credentials.

prn

instantiate

(Fn [(Ref Credentials a)] String)

converts a Credentials to a string.

realm

defn

(Fn [(Ref Credentials a)] (Maybe String))

                        (realm c)
                    

the realm auth-param, as (Maybe String).

scheme

instantiate

(Fn [(Ref Credentials a)] (Ref String a))

gets the scheme property of a Credentials.

scheme-is?

defn

(Fn [(Ref Credentials a), (Ref String b)] Bool)

                        (scheme-is? c name)
                    

whether the scheme is name, compared case-insensitively as RFC 7235 §2.1 requires.

set-params

instantiate

(Fn [Credentials, (Array (Pair String String))] Credentials)

sets the params property of a Credentials.

set-params!

instantiate

(Fn [(Ref Credentials a), (Array (Pair String String))] ())

sets the params property of a Credentials in place.

set-scheme

instantiate

(Fn [Credentials, String] Credentials)

sets the scheme property of a Credentials.

set-scheme!

instantiate

(Fn [(Ref Credentials a), String] ())

sets the scheme property of a Credentials in place.

set-token

instantiate

(Fn [Credentials, String] Credentials)

sets the token property of a Credentials.

set-token!

instantiate

(Fn [(Ref Credentials a), String] ())

sets the token property of a Credentials in place.

str

defn

(Fn [(Ref Credentials a)] String)

                        (str c)
                    

serializes back into a header value, which parses back into an equal Credentials. A token takes precedence over params, since RFC 7235 allows only one of the two. Param values are always quoted, which the grammar permits for any of them.

token

instantiate

(Fn [(Ref Credentials a)] (Ref String a))

gets the token property of a Credentials.

update-params

instantiate

(Fn [Credentials, (Ref (Fn [(Array (Pair String String))] (Array (Pair String String)) a) b)] Credentials)

updates the params property of a Credentials using a function f.

update-scheme

instantiate

(Fn [Credentials, (Ref (Fn [String] String a) b)] Credentials)

updates the scheme property of a Credentials using a function f.

update-token

instantiate

(Fn [Credentials, (Ref (Fn [String] String a) b)] Credentials)

updates the token property of a Credentials using a function f.