Skip to content

Commit 4762d34

Browse files
AuthorizeKey and UnityAccessDecorator
1 parent 6c44077 commit 4762d34

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

docs/server-authorization/AuthorizeKey.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
* [TemporaryPathCredentialsService](../server/TemporaryPathCredentialsService.md)
1313
* [VolumeService](../server/VolumeService.md)
1414

15+
!!! note
16+
`AuthorizeKey` is a Java annotation (see [9.6. Annotation Interfaces]({{ java.spec }}/jls-9.html#jls-9.6)).
17+
1518
Every operation of an API service is decorated with `AuthorizeKey` annotation for server authorization.
1619

1720
`AuthorizeKey` consists of a [SecurableType](../basic-server-access-control/index.md#securables) and an optional name of the securable.

docs/server-authorization/UnityAccessDecorator.md

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,26 @@ AccessDecorator checking [path]
5050

5151
`serve` [finds the service method](#findServiceMethod).
5252

53-
When found, `serve` finds the [AuthorizeExpression](#findAuthorizeExpression) and the [AuthorizeKey](#findAuthorizeKeys) annotations (if defined on the method).
53+
When found, `serve` finds the [@AuthorizeExpression](#findAuthorizeExpression) and the [@AuthorizeKey](#findAuthorizeKeys) annotations (if defined on the method and the parameters).
5454

55-
For the authorization expression and the authorization resource(s) found, `serve` [finds the principal](IdentityUtils.md#findPrincipalId) and [authorizeByRequest](#authorizeByRequest).
55+
Only when there are an authorize expression and keys found, `serve` [finds the principal](IdentityUtils.md#findPrincipalId) and [authorizeByRequest](#authorizeByRequest).
5656

57-
Otherwise, `serve` prints out the following WARN message to the logs:
57+
Otherwise, `serve` prints out one of the WARN messages to the logs and passes the request on to the target (_delegate_) service (as if no authorization were even attempted).
5858

59-
``` text
60-
Couldn't unwrap service.
61-
```
59+
??? note "WARN Messages"
60+
`serve` prints out one of the following WARN messages to the logs:
61+
62+
```text
63+
No authorization resource(s) found.
64+
```
65+
66+
```text
67+
No authorization expression found.
68+
```
69+
70+
```text
71+
Couldn't unwrap service.
72+
```
6273

6374
### Find Service Method { #findServiceMethod }
6475

@@ -96,7 +107,41 @@ List<KeyLocator> findAuthorizeKeys(
96107

97108
Learn more in the [Java Language Specification]({{ java.spec }}/jls-8.html#jls-8.4.3.2).
98109

99-
`findAuthorizeKeys`...FIXME
110+
`findAuthorizeKeys` finds [@AuthorizeKey](AuthorizeKey.md) annotations on the given `Method` ([Java]({{ java.api }}/java/lang/reflect/Method.html#getAnnotation(java.lang.Class))). If found, `findAuthorizeKeys` adds a locator with the following:
111+
112+
Source | Securable
113+
-|-
114+
`SYSTEM` | The `value`<br>of the [@AuthorizeKey](AuthorizeKey.md) annotation
115+
116+
`findAuthorizeKeys` finds [@AuthorizeKey](AuthorizeKey.md) annotations (incl. [@AuthorizeKeys](AuthorizeKeys.md)) on the method's parameters.
117+
118+
??? note "WARN Log Message"
119+
In case `findAuthorizeKeys` finds both [@AuthorizeKey](AuthorizeKey.md) and [@AuthorizeKeys](AuthorizeKeys.md) annotations, `findAuthorizeKeys` prints out the following WARN message to the logs:
120+
121+
```text
122+
Both AuthorizeKey and AuthorizeKeys present
123+
```
124+
125+
`findAuthorizeKeys` collects the `AuthorizeKey`s.
126+
127+
For keys with the key specified, `findAuthorizeKeys` adds a locator with the following:
128+
129+
Source | Securable | Key
130+
-|-|-
131+
`PAYLOAD` | The `value`<br>of the [@AuthorizeKey](AuthorizeKey.md) annotation | The `key`<br>of the [@AuthorizeKey](AuthorizeKey.md) annotation
132+
133+
Otherwise, `findAuthorizeKeys` finds parameters with `@Param` annotation. If found, `findAuthorizeKeys` adds a locator with the following:
134+
135+
Source | Securable | Key
136+
-|-|-
137+
`PARAM` | The `value`<br>of the [@AuthorizeKey](AuthorizeKey.md) annotation | The `value`<br>of the `@Param` annotation
138+
139+
??? note "WARN Log Message"
140+
In case `findAuthorizeKeys` finds no `@Param` annotation on the parameter, `findAuthorizeKeys` prints out the following WARN message to the logs:
141+
142+
```text
143+
Couldn't find param key for authorization key
144+
```
100145

101146
### Find Authorize Expression { #findAuthorizeExpression }
102147

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ extra:
119119
home: https://iceberg.apache.org
120120
java:
121121
version: 17
122+
api: https://docs.oracle.com/en/java/javase/17/docs/api/java.base
122123
spec: https://docs.oracle.com/javase/specs/jls/se17/html
123124
jcasbin:
124125
version: 1.55.0

0 commit comments

Comments
 (0)