wmo-im / wis2box

WIS2 in a box is a reference implementation of a WMO WIS2 Node
https://docs.wis2box.wis.wmo.int
Apache License 2.0
40 stars 16 forks source link

add secure data capability #20

Closed tomkralidis closed 2 years ago

tomkralidis commented 2 years ago

User story

As an operator, I want to add access control to some data so that sensitive resources require authentication and authorization.

Acceptance criteria

Definition of done

tomkralidis commented 2 years ago

Notes from 2022-03-09 discussion:

Terms

Authentication: verification of identity Authorization: verification of access

Scope

In:

Out:

Considerations

Next steps

petersilva commented 2 years ago

adding #140 as a pre-requisite for this.

tomkralidis commented 2 years ago

Simple example: https://medium.com/@ratrosy/building-a-basic-authorization-server-using-authorization-code-flow-c06866859fb1

petersilva commented 2 years ago

I just wanted to point out... in Sarracenia, we implemented bearer_token support to work with NOAA sites ( https://omisips1.omisips.eosdis.nasa.gov ) the above example implements an "access_token" I'm not sure what standards apply to this stuff or if everyone uses their own stuff and every client is supposed to use custom javascript... it's odd

https://oauth.net/2/bearer-tokens/#:~:text=Bearer%20Tokens%20are%20the%20predominant,such%20as%20JSON%20Web%20Tokens

https://swagger.io/docs/specification/authentication/bearer-authentication/

I'm not sure if the two things are describing the same mechanism or not ... the implementation of bearer token support was quite simple:

           headers = {'user-agent': 'Sarracenia ' + sarracenia.__version__}
            if self.bearer_token:
                logger.debug('bearer_token: %s' % self.bearer_token)
                headers['Authorization'] = 'Bearer ' + self.bearer_token
           ....
            urllib.request.Request(self.urlstr, headers=headers)

One just includes there Authorization header when opening the request. I get the feeling OAUTH2 is huge and has many options, and so one can have completely different implementations of "OAUTH2" that don't work with each other because they implement different options or parts of it. The spec is open to many different use cases.

might want to clarify what, beyond just OAUTH2, needs to be implemented.

Found a link about the different token varieties:

https://www.c-sharpcorner.com/article/accesstoken-vs-id-token-vs-refresh-token-what-whywhen/#:~:text=Access%20tokens%20are%20credentials%20used,that%20bearer%20tokens%20be%20protected.

perhaps good to target bearer_token as first pass, likely sufficient for needs. the access token stuff seems to include continuous replacement of tokens, and looks a lot more complicated for the client to deal with.

tomkralidis commented 2 years ago

We should use "static" tokens to alleviate users from refreshing tokens based on expiry/etc.

Needs to be shared across nginx and API.

webb-ben commented 2 years ago

@tomkralidis and I have been iterating a bit over the last couple of days. Going to collate some of the considerations we have discussed thus far. @petersilva interested to hear your thoughts!

Open /data/public/data/core/5/6/7/8/bar /data/public/data/recommended/11/22/33/44/baz

petersilva commented 2 years ago

I think we should constrain things to be at least entire folders aka topics... not allow some files under the same topic to have some restricted items and other public ones. I don´t think we can restrict more than that...

tomkralidis commented 2 years ago

@petersilva agree, for WAF access control is on directories, for the API, this equates to dataset collections.

webb-ben commented 2 years ago

I think we are all in agreement on this point

tomkralidis commented 2 years ago

Updates:

tomkralidis commented 2 years ago

We should also cover cases for embedded data. In this case, a possible option would be to have the entire channel to be authenticated. We should be able to advertise various data for various channels.

tomkralidis commented 2 years ago

Initial capability now in main branch.