-
Notifications
You must be signed in to change notification settings - Fork 113
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
IAM Action Documentation #1345
Comments
💭 I believe we already have a card for this somewhere. The problem is that autogenerating what API endpoints + methods are permissions is simple, but what they do will be manual documentation work. I wonder how this ties in with the current state of our API docs efforts... 😃 I'd think it would make sense if both "this is the action permission required to use this endpoint" and "this is what the endpoint does" was part of the API docs. |
we could break it up into those two subtasks? id really like to be able to get something out there even if it doesn't have the what they do part yet. |
The API work is ongoing, but if you're autogenerating you'll need to follow the Hugo Data Template workflow. The data goes into a folder in |
📜 some notes for backlog groomingfor the first part,
desirables
current state
possible approaches
The first approach is the conservative one, do more of what we know how to do. On the other hand, the second approach will probably have us end up in a state where the system is significantly simpler, without losing anything. There's no consumers of our GRPC API (yet, or even soon?) and when when there are, the extensions we've introduced are not adhering to any standard, so -- there's no benefit from having the permissions in the proto files. Except for keeping them close to the method definiton, and making them hard to miss. If they're in an extra file, you might miss them. We would add tests that yell if a method is defined that doesn't have a mapping. Besides being simpler, the other benefit from the second approach is that by decoupling the method mapping from the endpoint definition, we can make full use of grpc-gateway's features. Right now, for example, we cannot have patchy endpoints because they require a certain form of path that we cannot deal with in our simple method mapping logic. Also, the second approach lets us extend the per-endpoint information more easily: if we want our own format for descriptions, examples, whatnot, adding fields to a YAML doc is much simpler than threading this into our code generation plugin. (That is, if OpenAPI (== Swagger) is not sufficient for extra metadata.) more notes
|
💭 It would be really cool if the UI gave you an idea about what's up given your permissions... I.e. if some UI elements weren't hidden when you don't have the permissions to use them, but disabled instead, with the mouseover text (or something similar) indicating which permissions your lacking... |
Here's the location that I think covers AWS documentation: https://docs.aws.amazon.com/cognito/latest/developerguide/role-based-access-control.html |
this is there actions table they seem to have a page for every action... |
@msorens since you've asked in our discussion today, this would allow us to also take the |
Let's pull in @phiggins , who is working on autogenerating the api docs. |
@phiggins I've considered adding action/resource (or only action) to the swagger docs, but it seems the grpc-gateway code generator doesn't support such arbitrary key/val metadata additions on pairs of HTTP endpoint + HTTP method. (That is, I've asked around in the grpc-gateway channel of the gopher slack today...) -- This is the background for why I'd go with another YAML file instead. We could weave these together in the template, maybe...? 💭 |
The tools we're using to generate the swagger from proto files seem limited in their flexibility so I'm not sure how much value there is in pursuing that route. There is likely going to need to be post-processing scripting done to get all the stuff we want supported so using separate files to list the auth information seems ok to me. |
Before we develop something bespoke, I would like the opportunity to work with you on what you've developed. Looking at the needs that @srenatus has outlined in his discussion, we should discuss making the case for moving to the newer OpenAPI 3.0 Specification. In any event, let's make sure this work conforms to existing API documentation standards as well as the needs of user documentation. Thanks! |
OK so there are a few things here:
They should explain what kind of access an action grants you. In our system, actions roughyl map 1-to-1 to GRPC methods, and thus HTTP endpoint+verb pairs. What was outlined so far, would amount to _using the source of truth created in (1) for (3). From the discussion, it looks like what's generated "for free" in (2) is not what we want for API docs, so there's OpenAPI 3. I'm not sure what to make of that -- If we had OpenAPI 3 specs, and they would allow for an arbitrary field attached to a endpoint+verb pair, we could use them as source-of-truth for our needs in (1) and (3). However, I don't know if this is something the spec allows, and I don't know how close we are in terms of having an OpenAPI 3 spec at all, so I'd lean towards a very simple solution to (1) and (3), that, even if bespoke, will be nowhere near any kind of complete API docs. @kagarmoe @phiggins Am I misrepresenting the state of affairs wrt. API docs? What do you think about this ☝️? |
ℹ️Some notes from looking around...
|
@srenatus Your assessment is accurate, AFAIK. OpenAPI 3 looks like a nice evolution of the standard but we're limited in supporting it because of the tools we're using. |
ℹ️ We've opted for approach 2. Having the authz mappings in a YAML file will also not lock us in in any way when we'd later want to weave this information into some OpenAPI 3 spec. |
I'm not sure that I completely understand the proposed documentation. Is the plan to create a document mapping the GRPC methods and HTTP endpoint+verb pairs? Who is the audience for this documentation? What information question does it answer for our customers that wouldn't be answered by good API documentation? |
@kagarmoe one by one 😃
Besides the one-to-one mapping between GRPC methods and HTTP endpoint+verb pairs, there's a third thing: IAM actions and resources. And that mapping is what we're looking to shine a light on.
Anyone writing IAM policies who wants to understand what granting a user access to Update Probably more often than not, the question will be: My request to XYZ failed with a 403, which policy do I need to create to make it succeed?
The mentioned mapping of IAM action/resource pairs to HTTP endpoints+verbs. There's a table somewhere, I believe, for IAMv1, which is likely outdated and wrong. Ideally, this would find a place in good API docs, for sure. However, from the stuff above, it seems that OpenAPI v2 doesn't allow for putting arbitrary key-val pairs anywhere. @susanev happy to zoom if that's what everyone prefers 😃 (Time[zones] permitting.) |
I'm not sure that these ideas about the limitations of the OpenAPI 2.0 spec are correct. This spec can handle OAuth2 Security requirements. OpenAPI is also extensible. Extensions & Implementations API Handyman blog by Arnaud Lauret on Extensions I think that I'm having trouble visualizing what this doc needs to be. I'd love it if someone could mock up some content for me, so I can understand the information need and solution a bit better. Could you whip something up (not a full doc, just an example) so we can meet on it? Thanks! NB: I think finally get what you are after, thanks to @susanev . I need to think about it & play with this a bit. |
@kagarmoe thanks for all those resources! 😃
Ok, I might have been inexact here: I've been looking at openapi 2 through the lense of what grpc-gateway's code generator lets us use right now. This doesn't meant that we cannot either improve that one (we've done that before), or find other ways to amend our generated openapi2 docs. It looks like @phiggins already has started doing that for custom endpoints.
The example linked to looks like it could be (ab)used for our purposes:
So we could say that what is a scope in the spec is an action in our Automate API docs. We'd ignore that there's resources. However, it's OpenAPI 3.0. Not sure if v2 knows of the same thing. This, however,
looks like pretty much what we'd need 💡 -- @phiggins do you know a way to add some of these extension fields, too? Either using proto3 method options or using some post-processing step? For this card, however, I'd uphold that unless we can use Update We can misuse the oauth2 scope annotation (per-method, or "operation") in v2 using our current tooling. This is the diff, first the piece I've added to @phiggins's PR in #1412, and then how it boils down to OpenAPI v2 json: diff --git a/components/automate-gateway/api/compliance/reporting/reporting.proto b/components/automate-gateway/api/compliance/reporting/reporting.proto
index 0a0ab94ce..68dc1c0b3 100644
--- a/components/automate-gateway/api/compliance/reporting/reporting.proto
+++ b/components/automate-gateway/api/compliance/reporting/reporting.proto
@@ -33,6 +33,14 @@ service ReportingService {
description: "List all reports optionally using filters";
summary: "List reports";
tags: "Compliance Reporting Reports";
+ security: {
+ security_requirement: {
+ key: "OAuth2";
+ value: {
+ scope: "compliance:reports:list";
+ }
+ }
+ }
};
};
diff --git a/components/automate-gateway/api/compliance/reporting/reporting.swagger.json b/components/automate-gateway/api/compliance/reporting/reporting.swagger.json
index 4e92f0985..edb400d54 100644
--- a/components/automate-gateway/api/compliance/reporting/reporting.swagger.json
+++ b/components/automate-gateway/api/compliance/reporting/reporting.swagger.json
@@ -151,6 +151,13 @@
],
"tags": [
"Compliance Reporting Reports"
+ ],
+ "security": [
+ {
+ "OAuth2": [
+ "compliance:reports:list"
+ ]
+ }
]
}
}, My only concern there is the "misuse" bit. The security scheme Automate uses for API authorization is not OAuth2, and to make things worse, it's using OpenID Connect, a sort-of specialization of OAuth2, for authenticating users. So, on the authentication+authorization peninsula of Automate-land, there is scopes, but they're different; and not used for authorization in the oauth2 sense. My fear is that misuing this field like that will foster confusion. I think we'd be better off exposing custom extensions of the openapiv2 annotations -- i.e., contrbute something to grpc-gateway. |
Update I've looked a little deeper into this, see grpc-ecosystem/grpc-gateway#1033. |
an additional option for this, as we need to complete something to inform folks of the actions possible is to manually document a subset of the possible actions until we can come back and autogenerate it. |
Discussion with @susanev, @tylercloke, and @msorens: |
the rest of this work has been deprioritized, so closing. |
Problem: Users do not have the information they need to define custom roles and policies.
Overview
Currently, we do not provide a reference for the many actions that are possible to use when defining a role to be used in a policy. Let's autogenerate a table of those actions that include the action identifier, and a brief optional description based on annotations. The descriptions will be important for anything that has different names then what is displayed in the ui, some examples are node manager vs node integration and event vs action.
Design Details
automate/components/automate-chef-io/data/docs/
automate/components/automate-chef-io/layouts/
Subtasks
Reference
The text was updated successfully, but these errors were encountered: