Skip to content

Commit 07c6430

Browse files
committed
merge: '3-implement-aif-support' into 'main'
Resolve "Implement AIF support" Closes #3 See merge request namib-master/libraries/dcaf-rs!2
2 parents 4f780a6 + ec4db75 commit 07c6430

File tree

12 files changed

+1121
-88
lines changed

12 files changed

+1121
-88
lines changed

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [0.2.0] --- 2022-04-05
8+
This release focuses on introducing [AIF] and [libdcaf]-support.
9+
10+
### Added
11+
- Support for scopes using the
12+
[Authorization Information Format (AIF) for ACE](https://datatracker.ietf.org/doc/html/draft-ietf-ace-aif).
13+
For this purpose, the following types have been added:
14+
- `AifEncodedScope`, representing an AIF-encoded scope (surprise)
15+
- `AifEncodedScopeElement`, a single element in an AIF-encoded scope
16+
- `AifRestMethodSet`, encoding a set of REST methods
17+
- Support for scopes used by the [libdcaf] implementation
18+
(a variant of AIF-encoded scopes).
19+
20+
### Fixed
21+
- Binary-encoded scopes are now properly serialized.
22+
- Some incorrect documentation regarding scopes has been corrected.
23+
24+
## [0.1.0] --- 2022-04-02
25+
As this is the first release, lots of basic functionality has been setup.
26+
For more extensive documentation, consult the
27+
[crate-level documentation](https://docs.rs/dcaf).
28+
29+
### Added
30+
- CBOR de-/serializable model of the ACE-OAuth framework has been added:
31+
- Binary- and text-encoded scopes
32+
- Access token requests and responses
33+
- Authorization server request creation hints
34+
- Error responses
35+
- Various smaller types (`AceProfile`, `GrantType`, `ProofOfPossessionKey`, `TokenType`...)
36+
- Use `serialize_into` or `deserialize_from` to serialize and deserialize these types.
37+
- Methods to create and work with access tokens:
38+
- `encrypt_access_token`
39+
- `decrypt_access_token`
40+
- `sign_access_token`
41+
- `verify_access_token`
42+
- `get_token_headers` (to extract headers from an opaque token)
43+
- Related: Various COSE Cipher traits intended for users to implement,
44+
used in the above methods for cryptographic operations:
45+
- `CoseCipherCommon` (to set headers specific to the cipher)
46+
- `CoseEncrypt0Cipher`
47+
- `CoseVerify1Cipher`
48+
- `CoseMac0Cipher`
49+
- Constants describing CBOR abbreviations of various ACE-OAuth fields
50+
- `no_std` support
51+
52+
[0.1.0]: https://github.com/namib-project/dcaf-rs/releases/tag/v0.1.0
53+
[0.2.0]: https://github.com/namib-project/dcaf-rs/compare/v0.1.0...v0.2.0
54+
[AIF]: https://datatracker.ietf.org/doc/html/draft-ietf-ace-aif
55+
[libdcaf]: https://gitlab.informatik.uni-bremen.de/DCAF/dcaf

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dcaf"
33
description = "An implementation of the ACE-OAuth framework"
4-
version = "0.1.0"
4+
version = "0.2.0"
55
edition = "2021"
66
authors = ["Falko Galperin <falko1@uni-bremen.de>"]
77
rust-version = "1.58"
@@ -27,6 +27,7 @@ erased-serde = { version = "^0.3.18", default-features = false, features = ["all
2727
derive_builder = { version = "^0.10.2", default-features = false }
2828
strum = { version = "^0.24", default-features = false, features = ["derive"] }
2929
strum_macros = { version = "^0.24", default-features = false }
30+
bitflags = "1.3"
3031

3132
[dev-dependencies]
3233
hex = { version = "^0.4.3" }

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ while `alloc` is still needed, this crate offers
4040
## Usage
4141
```toml
4242
[dependencies]
43-
dcaf = { version = "^0.1.0" }
43+
dcaf = { version = "^0.2.0" }
4444
```
4545
Or, if you plan to use this crate in a `no_std` environment:
4646
```toml
4747
[dependencies]
48-
dcaf = { version = "^0.1.0", default-features = false }
48+
dcaf = { version = "^0.2.0", default-features = false }
4949
```
5050

5151
## Example
@@ -58,7 +58,7 @@ quickly introduce both of these here.
5858
[For example](https://www.ietf.org/archive/id/draft-ietf-ace-oauth-authz-46.html#figure-7), say you (the client) want to
5959
request an access token from an Authorization Server. For this, you'd need to create an `AccessTokenRequest`, which has
6060
to include at least a
61-
`client_id`. We'll also specify an audience, a scope (using `TextEncodedScope`---note that binary-encoded scopes would
61+
`client_id`. We'll also specify an audience, a scope (using `TextEncodedScope`---note that binary-encoded scopes or AIF-encoded scopes would
6262
also work), as well as a
6363
`ProofOfPossessionKey` (the key the access token should be bound to) in the `req_cnf` field.
6464

@@ -173,6 +173,9 @@ When implementing any of the specific COSE ciphers, you'll also need to implemen
173173
`CoseCipherCommon` trait, which can be used to set headers specific to your COSE cipher
174174
(e.g. the used algorithm).
175175

176+
## Changelog
177+
You can find a list of changes in [CHANGELOG.md](CHANGELOG.md).
178+
176179
## License
177180

178181
Licensed under either of

src/common/cbor_map/mod.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -276,24 +276,13 @@ pub trait ToCborMap: private::Sealed {
276276
}
277277
}
278278

279-
/// Decodes the given specific `scope` of type `T` into the general [`Scope`] type.
279+
/// Decodes the given specific `scope` into the general [`Scope`] type.
280280
///
281281
/// # Errors
282282
/// - If `scope` is not a valid scope.
283-
pub(crate) fn decode_scope<T, S>(scope: T) -> Result<Scope, TryFromCborMapError>
284-
where
285-
S: TryFrom<T>,
286-
Scope: From<S>,
287-
S::Error: Display,
288-
{
289-
match S::try_from(scope) {
290-
Ok(scope) => Ok(Scope::from(scope)),
291-
Err(e) => {
292-
return Err(TryFromCborMapError::from_message(format!(
293-
"couldn't decode scope: {e}"
294-
)));
295-
}
296-
}
283+
pub(crate) fn decode_scope(scope: Value) -> Result<Scope, TryFromCborMapError> {
284+
Scope::try_from(scope)
285+
.map_err(|e| TryFromCborMapError::from_message(format!("couldn't decode scope: {e}")))
297286
}
298287

299288
/// Decodes the given `number` Integer into a more specific integer of type `T`.

0 commit comments

Comments
 (0)