Skip to content

Commit 5e762d5

Browse files
fenekkuppanero
authored andcommitted
config: add steps to permission configuration
closes inveniosoftware/invenio-records-permissions#43
1 parent ce09fdc commit 5e762d5

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

docs/develop/config.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ curl -k -XPOST -H "Content-Type: application/json" https://localhost:5000/api/re
6464
},
6565
"identifiers": [
6666
{
67-
"identifier": "10.9999/rdm.9999999",
67+
"identifier": "10.9999/rdm.0",
6868
"scheme": "DOI"
69-
}, {
70-
"identifier": "9999.99999",
71-
"scheme": "arXiv"
7269
}
7370
],
7471
"creators": [
@@ -79,7 +76,7 @@ curl -k -XPOST -H "Content-Type: application/json" https://localhost:5000/api/re
7976
"family_name": "Brutus",
8077
"identifiers": [
8178
{
82-
"identifier": "9999-9999-9999-9999",
79+
"identifier": "9999-9999-9999-9990",
8380
"scheme": "Orcid"
8481
}
8582
],
@@ -101,7 +98,7 @@ curl -k -XPOST -H "Content-Type: application/json" https://localhost:5000/api/re
10198
],
10299
"descriptions": [
103100
{
104-
"description": "A story on how Julio Cesar relates to Gladiator.",
101+
"description": "A story about how permissions work.",
105102
"type": "Abstract",
106103
"lang": "eng"
107104
}
@@ -130,7 +127,31 @@ As you can see, the server could not know if we are authenticated/superuser and
130127
}
131128
```
132129

133-
!!!todo
134-
Document how to generate an API token when permissions via token work.
130+
Let's create a user with the right permission, generate her token and use the API
131+
with it.
135132

136-
Revert the changes in `invenio.cfg` and restart the server to get back to where we were.
133+
``` bash
134+
pipenv run invenio users create [email protected] --password=123456 --active
135+
```
136+
137+
``` bash
138+
pipenv run invenio roles add [email protected] admin
139+
```
140+
141+
Login through the browser as `[email protected]` with password `123456`. Then
142+
in the dropdown menu of the username (top-right), select `Applications`. Then
143+
click on `New token`, name your token and click `Create`. Copy this token (we
144+
will refer to it as `<your token>`) and put it in the API call as such:
145+
146+
``` bash
147+
curl -k -XPOST -H "Authorization:Bearer <your token>" -H "Content-Type: application/json" https://localhost:5000/api/records/ -d '{
148+
...<fill with the above>...
149+
}'
150+
```
151+
152+
And it works! That's because InvenioRDM creates an `admin` role with super user
153+
access permissions when initially setting up the database. Above, we set
154+
`[email protected]` to be an admin, so that user can create records.
155+
156+
Revert the changes in `invenio.cfg` and restart the server to get back to where
157+
we were.

0 commit comments

Comments
 (0)