@@ -151,29 +151,33 @@ const {
151
151
decodedToken,
152
152
username,
153
153
roles,
154
+ resourceRoles,
154
155
keycloak,
155
156
156
157
// Functions
157
158
hasRoles,
159
+ hasResourceRoles,
158
160
} = useKeycloak ()
159
161
```
160
162
161
- | State | Type | Description |
162
- | --------------- | --------------------------- | ------------------------------------------------------ |
163
- | isAuthenticated | ` Ref<boolean> ` | If ` true ` the user is authenticated. |
164
- | isPending | ` Ref<boolean> ` | If ` true ` the authentication request is still pending. |
165
- | hasFailed | ` Ref<boolean> ` | If ` true ` authentication request has failed. |
166
- | token | ` Ref<string> ` | ` token ` is the raw value of the JWT token. |
167
- | decodedToken | ` Ref<T> ` | ` decodedToken ` is the decoded value of the JWT token. |
168
- | username | ` Ref<string> ` | ` username ` the name of our user. |
169
- | roles | ` Ref<string[]> ` | ` roles ` is a list of the users roles. |
170
- | keycloak | ` Keycloak.KeycloakInstance ` | ` keycloak ` is the instance of the keycloak-js adapter. |
163
+ | State | Type | Description |
164
+ | --------------- | ------------------------------ | ------------------------------------------------------------------- |
165
+ | isAuthenticated | ` Ref<boolean> ` | If ` true ` the user is authenticated. |
166
+ | isPending | ` Ref<boolean> ` | If ` true ` the authentication request is still pending. |
167
+ | hasFailed | ` Ref<boolean> ` | If ` true ` authentication request has failed. |
168
+ | token | ` Ref<string> ` | ` token ` is the raw value of the JWT token. |
169
+ | decodedToken | ` Ref<T> ` | ` decodedToken ` is the decoded value of the JWT token. |
170
+ | username | ` Ref<string> ` | ` username ` the name of our user. |
171
+ | roles | ` Ref<string[]> ` | ` roles ` is a list of the users roles. |
172
+ | resourceRoles | ` Ref<Record<string, string[]> ` | ` resourceRoles ` is a list of the users roles in specific resources. |
173
+ | keycloak | ` Keycloak.KeycloakInstance ` | ` keycloak ` is the instance of the keycloak-js adapter. |
171
174
172
175
#### Functions
173
176
174
- | Function | Type | Description |
175
- | -------- | ------------------------------ | ------------------------------------------------------------ |
176
- | hasRoles | ` (roles: string[]) => boolean ` | ` hasRoles ` returns true if the user has all the given roles. |
177
+ | Function | Type | Description |
178
+ | ---------------- | ------------------------------------------------ | ---------------------------------------------------------------------------------- |
179
+ | hasRoles | ` (roles: string[]) => boolean ` | ` hasRoles ` returns true if the user has all the given roles. |
180
+ | hasResourceRoles | ` (roles: string[], resource: string) => boolean ` | ` hasResourceRoles ` returns true if the user has all the given roles in a resource. |
177
181
178
182
# License
179
183
0 commit comments