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

Multiple OAuth 2.0 flows in security definitions #929

Closed
farshidtz opened this issue Jul 17, 2020 · 3 comments
Closed

Multiple OAuth 2.0 flows in security definitions #929

farshidtz opened this issue Jul 17, 2020 · 3 comments
Labels
Propose closing Problem will be closed shortly if there is no veto. Security

Comments

@farshidtz
Copy link
Member

farshidtz commented Jul 17, 2020

This is relevant to issue #901 and can be resolved to an extent with the support for applying security schemes in an OR fashion.

It is very common to have things with endpoints that perform authorization based on one or more OAuth 2.0 flows. Other OAuth 2.0 flows are being added to the specs, and all relevant forms in a TD will have to be repeated to specify the support for each flow (e.g. code, client, or device). Note that for some OAuth 2.0 flows, the server (thing) only receives and validates a token from the user, regardless of the flow which was followed to obtain that token from the authentication server.

Consider the following, a TD with one form and three OAuth 2.0 flows:

{
    "securityDefinitions": {
        "oauth2_code": {
            "scheme": "oauth2",
            "flow": "code",
            "authorization": "https://example.com/authorization",
            "token": "https://example.com/token",
            ...
        },
        "oauth2_client": {
            "scheme": "oauth2",
            "flow": "client",
            "authorization": "https://example.com/authorization",
            "token": "https://example.com/token",
            ...
        },
        "oauth2_device": {
            "scheme": "oauth2",
            "flow": "device",
            "authorization": "https://example.com/authorization",
            "token": "https://example.com/token",
            ...
        }
    },
    "security": ["oauth2_code"],
    "properties": {
        "status": {
            "forms": [{
                "href": "https://scopes.example.com/status"
            },{
                "href": "https://scopes.example.com/status",
                "security": ["oauth2_client"]
            },{
                "href": "https://scopes.example.com/status",
                "security": ["oauth2_device"]
            }]
        }
    },
    ...
}

A large part of TD is dedicated to describe something that the authentication server provides, rather than the thing.

If the type of flow attribute is extended from string to string or Array of string. The above TD can be reduced to:

{
    "securityDefinitions": {
        "oauth2_sc": {
            "scheme": "oauth2",
            "flow": ["code", "client", "device"], // proposed Array of string OR introduce new flows field.
            "authorization": "https://example.com/authorization",
            "token": "https://example.com/token",
            ...
        }
    },
    "security": ["oauth2_sc"],
    "properties": {
        "status": {
            "forms": [{
                "href": "https://scopes.example.com/status"
            }]
        }
    },
    ...
}

OpenAPI's OAuth 2.0 spec have a different structure, but it still allows definition of array of flows, even though the security schemes are applied as OR.

@farshidtz
Copy link
Member Author

One issue with this proposal is that there will be no way of picking a subset of flows or overriding the default set in a form. For example, a management endpoint may just support code flow. In this case, the TD should define another securityDefinition with just one flow and associate it with the management endpoint.

@mmccool
Copy link
Contributor

mmccool commented Jul 20, 2020

So I like the idea of having an array of flows in the definition. And if you have to specify a specific flow in a form then you can just use separate security definitions. This also (unlike changing AND to OR) would not break backward compatibility.

@farshidtz
Copy link
Member Author

Similar feature is not provided using the combo security scheme:
https://www.w3.org/TR/wot-thing-description11/#combosecurityscheme

#944

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Propose closing Problem will be closed shortly if there is no veto. Security
Projects
None yet
Development

No branches or pull requests

3 participants