Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for authorization #11

Open
omerlh opened this issue Dec 13, 2018 · 1 comment
Open

Add support for authorization #11

omerlh opened this issue Dec 13, 2018 · 1 comment

Comments

@omerlh
Copy link
Contributor

omerlh commented Dec 13, 2018

Currently, AirBag supports only authentication. Let's add support for authorization!
What we can do?
Define a mapping between claims to paths. For example:

[
{
   "path": "/api/v1/secure"
   "claims":
   {
       "key": "scope",
       "value": ["super-secure"]
}
]

Another issues is how you tests your service configuration.
What do you think?

@Soluto Soluto deleted a comment from AvivRubys Dec 13, 2018
@Soluto Soluto deleted a comment from guysegal Dec 13, 2018
@Yshayy
Copy link

Yshayy commented Dec 13, 2018

I think AirBag shares lots of functionality with OPA.
It might be possible to use OPA as alternative as rego is more expressive.
I think something like this:
Authority: "oidc/discovery endpoint"
Issuer: ...
Audience: ...

Policy: ./policies/auth.rego # or
Policies: ./policies

### policies/auth.rego

token = {"payload": payload} { io.jwt.decode(http_api.token, [_, payload, _]) }

default allow = false

# Allow specific app access to all paths/methods
allow {
  http_api.method = "GET"
  token.sub = "my-app-id"
}

# Allow user to get only his details
allow {
  token.sub = username
  http_api.method = "GET"
  http_api.path = ["users", "details", username]
}

# Allow users with group user-admin to get details for any user
allow {
  token.groups[_] = "user-admin"
  http_api.method = "GET"
  http_api.path = ["users", "details", _]
}

# Allow diagnostics services to check metrics/health endpoints
is_diagnostics_service {
    # can be kube master/nodes   
    # or/and Promethus pods when using stateful set
    request.ip = net.cidr_overlap(ip, "127.0.0.1/24") 
}


diagnostics_path {  http_api.path = ["metrics"] }
diagnostics_path {  http_api.path = ["health"] }

allow {
    http_api.method = "GET"
    diagnostics_path
    is_diagnostics_service
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants