Skip to content

Instantly share code, notes, and snippets.

@dukex
Created February 27, 2025 02:49
Show Gist options
  • Save dukex/8ec14dc09ec6f26339ba506448731f07 to your computer and use it in GitHub Desktop.
Save dukex/8ec14dc09ec6f26339ba506448731f07 to your computer and use it in GitHub Desktop.
terraform + openfga
terraform {
required_providers {
openfga = {
source = "mauriceackel/openfga"
}
}
}
provider "openfga" {
api_url = "http://localhost:8080"
}
resource "openfga_store" "example" {
name = "example_store_name"
}
data "openfga_authorization_model_document" "model" {
mod_file_path = "${path.root}/models/fga.mod"
}
resource "openfga_authorization_model" "example" {
store_id = openfga_store.example.id
model_json = data.openfga_authorization_model_document.model.result
}
module core
type user
type organization
relations
define member: [user]
define admin: [user]
type group
relations
define member: [user]
define can_edit: [user]
schema: '1.2'
contents:
- core.fga
- issue-tracker/projects.fga
- issue-tracker/tickets.fga
- wiki.fga
module issue-tracker
extend type organization
relations
define can_create_project: admin
type project
relations
define organization: [organization]
define viewer: member from organization
module issue-tracker
type ticket
relations
define project: [project]
define owner: [user]
module wiki
extend type organization
relations
define can_create_space: admin
type space
relations
define organization: [organization]
define can_view_pages: member from organization
type page
relations
define space: [space]
define owner: [user]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment