Commit graph

39 commits

Author SHA1 Message Date
tgruben
2f1beaf119
Dataframe (#2241)
* Dataframe
2022-11-21 17:38:48 -06:00
Garrison Davis
0f5a56c958 Stop using string keys in contexts
This fixes the OriginalIP and RequestUserID in the main featurebase
package, and the Access and Refresh tokens, the UserInfo, and the
[]string of Indexes passed with context.Context(s) in the authn package.

An empty struct was used for all of these keys (and relevant helper
functions we added) to avoid allocations where possible while still
using the context functionality.

Some of the logic in the server.GetIndexes function was fixed.
2022-11-04 15:01:40 -06:00
Samir Patel
3c2ef484bd
[FB-1621] account for token expiration as float and int (#2188)
* account token expiration as float and int

* update tests
2022-08-10 17:26:10 -05:00
reesporte
8ba81643d2
[FB-1379] Create a featurebase subcommand to obtain an auth token (#2079)
* Add CleanOAuthConfig endpoint

We will use this to get the OAuthConfig information, without the client secret, from
FeatureBase without having to have access to the config file. This will be useful
for the auth-token subcommand.

* Add string manipulation utility functions

Go doesn't have native support for these kind of things, so I added this to make it
easier to do string reversal, and replacing the first string encountered from the
end of the string to the front.

* Add auth-token subcommand

This is for work on [FB-1379](https://molecula.atlassian.net/browse/FB-1379).

We need this new auth-token subcommand to allow users to get access and refresh
tokens without having to login to featurebase via the UI. This commit adds that
functionality.

* error on oauth endpoint if auth isn't on

* https as default scheme in cmd, not internalclient
2022-05-26 11:35:51 -05:00
reesporte
60e6900c2e
Add refresh token header/cookie (#2071)
* Add refresh token header/cookie

As part of work on automatic refreshing of access tokens in the grafana plugin
(FB-1377), we will now accept a refresh token in the "X-Molecula-Refresh-Token"
header or the "refresh-molecula-chip" cookie.

This refresh token will be used if the access token is expired. To achieve this,
there was a lot of plumbing that had to be done. Here is a list of some of it:

* Added lots of constants for the new values.
* Removed token cache, since we will be keeping state on the clients.
* We now only refresh tokens when they are expired, which is more inline with the
  OAuth spec.
* Refactored SetGRPCMetadata to be simpler to read.
* Refactored AddAuthToken.
* Update failing tests.
* We now don't split GRPC cookies on ";". Not sure why we did that before tbh.

I also added TODOs to add the refresh token to other subcommands. This is out of
scope for my current ticket, but it would be nice to have in the future.

* remove unnecessary context from Authenticate

* Add comments on why we check both cases for headers

It's because some GRPC clients lowercase metadata names. I've run into issues with
this enough that I think it's worth the extra checks. We prefer lowercase though,
because that's "standard".

* Fix test that broke during rebase
2022-05-20 16:12:27 -05:00
souhailanoor
3986e202bf
FB-1378: Use IP whitelisting for ingest authentication and authorization (#2070)
* Use IP whitelisting for ingest
For ingest, use configured IPs to authenticate the requests.
Auth-token will no longer be used for requests from ingest consumers.
If IP in request is in configured IPs, authenticate and authorize as an admin.
If IP in request is not in configured IPs, proceed with the standard authentication/authorization using ADD.

* need to remove port from client IP

* addressed review comments
2022-05-20 14:57:05 -05:00
reesporte
5e1df3f30a
[fb-1377] SetGRPCMetadata should always set the cookie, whether there was a cookie there to begin with or not (#2065)
* make CookieName an exported constant

* fix SetGRPCMetadata

this will actually set the grpc metadata even if there are no cookies in the
metadata already.

* gofmt yourself
2022-05-16 17:07:02 -05:00
reesporte
f224e64bc3 setup auth cluster infra
also add test for sup218

Co-authored-by: rachithrr <rachith.ramaswamy@molecula.com>
Co-authored-by: bruce-b-molecula <bruce.baranowski@molecula.com>
2022-04-14 09:37:52 -05:00
reesporte
1060520fa7 add better error messaging for if the test is empty 2022-04-14 09:37:33 -05:00
Samir Patel
ef6decf63a update handler tests 2022-04-11 10:42:14 -05:00
Samir Patel
bddccf6ead add http status check to authenticate 2022-04-11 10:42:14 -05:00
Samir Patel
eea6a40fe0 Iterate through group membership http response
Follows the nextLink in http response to iterate through
paginated group membership response in order to obtain all
groups that the user is a member of.

Also, checks cache to make sure we don't add empty groups
to the cache.
2022-04-11 10:42:14 -05:00
reesporte
88d2914b15 fb1172: enable refresh tokens
- rip out gobby stuff
- add tokenCache, groupsCache
- refresh the token if needed
- set cookies after authenticate
- remove signature validation, the IDP does that for us
- added way more unit tests
- update older tests to use new API
- add fake idp to authcluster tests
2022-02-07 13:42:11 -06:00
reesporte
836df379ac add test coverage
for the following auth related packages:
* authn
* http
* server

fix minor bugs, do some cleaning up, etc in `authn/authenticate.go` and `http/handler.go`
2022-01-21 13:57:47 -06:00
Ben Johnson
9ebf0e2119 Upgrade go.mod to featurebase/v3 2022-01-21 10:57:05 -07:00
reesporte
cf2410fea6 addresses multiple authn/z tickets
* fb-998 - authn/z enabled in handlers (kitchen-sink ticket)
    - authorization is enabled through the use of a bearer token (using header "Authorization")
    - authorization may occur through the use of an "Authorization" header or "molecula-chip" cookie
    - ui is updated for changes to handler
* fb-1131 - protect grpc endpoints
    - GRPC endpoints now check authorization if auth is enabled
* fb-1129 - inter-node communication
    - the following endpoints use the secretKey for authentication:
        - /internal/cluster/message: POST
        - /internal/translate/data: GET, POST

* added test to api_test.go (TestAuth_MultiNode) testing various auth/permissions stuff on a multi-node cluster

not included:
    - fb-1130 - filter response of endpoints
    - fb-1109 - improved audit logging

@jaffee [are you not entertained](https://www.youtube.com/watch?v=mutgotxrcqg)

Co-authored-by: souhailanoor <90720110+souhailanoor@users.noreply.github.com>
Co-authored-by: tgruben <tgruben@gmail.com>
Co-authored-by: 54mir <48686912+54mir@users.noreply.github.com>
Co-authored-by: kcrodgers24 <49999391+kcrodgers24@users.noreply.github.com>
2022-01-14 12:31:32 -06:00
reesporte
fd896de270 rename CookieValue to AuthContext
because we're not using cookies anymore
2022-01-05 12:10:33 -06:00
reesporte
e335886741 adding Groups Struct back in
"It was pure hubris that brought us to this point."
2022-01-04 16:23:25 -06:00
reesporte
8d6490329b Merge branch 'master' into protect-endpoints 2022-01-04 16:18:18 -06:00
Samir Patel
23a1b4c536 revisions and docs 2022-01-04 16:02:25 -06:00
Samir Patel
414dff1d22 revisions 2022-01-03 22:56:21 -06:00
Samir Patel
a7fada30dd revisions 1 2022-01-03 20:43:51 -06:00
reesporte
9b77432952 fix bad formatting 2021-12-29 14:22:29 -06:00
reesporte
2847c22a4c linter things 2021-12-29 11:06:58 -06:00
Samir Patel
8b40c6bf7b rm comments 2021-12-22 13:47:16 -06:00
Samir Patel
b8b4425d4f clean up 2021-12-22 12:05:24 -06:00
Samir Patel
52d941d127 more tests 2021-12-22 11:31:37 -06:00
Samir Patel
10a7aa55ea same-site strict 2021-12-20 18:00:13 -06:00
Samir Patel
6faa889bfb move logout url to conf 2021-12-20 14:30:19 -06:00
Samir Patel
405692e376 Update authn/authenticate_test.go
Co-authored-by: souhailanoor <90720110+souhailanoor@users.noreply.github.com>
2021-12-20 13:16:34 -06:00
Samir Patel
e7f4eb1e36 response codes 2021-12-20 12:28:17 -06:00
Samir Patel
0d52a952e0 resolve some comments 2021-12-19 23:33:44 -06:00
Samir Patel
7ce07d4e4a settings 2021-12-17 11:42:02 -06:00
Samir Patel
3b58e887ed add group lenth check 2021-12-17 11:34:48 -06:00
Samir Patel
c2d51a2257 remove settings 2021-12-17 10:00:21 -06:00
Samir Patel
1555746ff1 test 2021-12-16 23:53:30 -06:00
Samir Patel
db2263465b tests 2021-12-16 23:39:58 -06:00
Samir Patel
eb693beb0b add authN login test 2021-12-16 20:35:34 -06:00
Samir Patel
b082a318f3 move authN to its own package 2021-12-16 20:34:09 -06:00