goauthentik / goauthentik/authentik
Allow blueprint entries to be created with !Enumerate
- Dominant language
- Python
- Stars
- 25.6k
- Forks
- 2k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 659
Description
**Is your feature request related to a problem? Please describe.**
When using the !Enumerate tag to generate entries the blueprint loader throws the error
> dacite.exceptions.WrongTypeError: wrong value type for field "entries" - should be "list" instead of value "" of type "Enumerate". Being able to use Enumerate to generate blueprint entries, for example: a set of groups or users, would be really useful.
**To Reproduce**
Load the following blueprint
```
version: 1
metadata:
name: Group - Application
context:
name: application
groups:
- admin
- user
- viewer
entries: !Enumerate [ !Context groups,
SEQ,
{
"model": "authentik_core.group",
"id": !Format [ "%s-%s-group", !Context name, !Value 0 ],
"identifiers": {
"attributes": {
"test": !Value 0
}
},
"attrs": {
"is_superuser": false,
"name": !Format [ "%s-%s", !Context name, !Value 0 ]
}
}
]
```
**Expected behavior**
Expect blueprint to generate multiple entries
**Version and Deployment (please complete the following information):**
- authentik version: 2012.12.3
- Deployment: helm
**Additional context**
Potential fix
Not sure if this will work as it looks like a BlueprintEntry is part of the context for parsing yaml tags so something else might be needed as well.
https://github.com/goauthentik/authentik/blob/6bcacd744bcd7e2d43ff18745407191fc5bbdd4c/authentik/blueprints/v1/common.py#L196
```
@dataclass
class Blueprint:
"""Dataclass used for a full export"""
version: int = field(default=1)
- entries: list[BlueprintEntry] = field(default_factory=list)
+ entries: Union[list[BlueprintEntry], Enumerate] = field(default_factory=list)
context: dict = field(default_factory=dict)
metadata: BlueprintMetadata | None = field(default=None)
```
Contributor guide
Assessment
This issue has not been assessed yet.