This repository has been archived by the owner on Mar 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Support notifications to users with private email ( using fabric8 service account ) #54
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3598b0a
start using latest auth
sbose78 458aaa3
fix tests
sbose78 c89add7
get sa token
sbose78 8a0e7d3
add error check;
sbose78 cceda60
inject service account token on startup
sbose78 800f29c
remove the WITs user api call
sbose78 28bd7c1
remove the WITs user api call
sbose78 edbd9f2
remove the WITs user api call
sbose78 616543e
delete the right stuff during make clean
sbose78 d07b361
add custom code for user api client
sbose78 6dbc3e3
remove unused import
sbose78 1959cb8
Merge remote-tracking branch 'upstream/master' into use-service-ac
sbose78 11e52e1
cleanup
sbose78 cc35683
remove unused import
sbose78 b5330b8
Merge remote-tracking branch 'upstream/master' into use-service-ac
sbose78 3205a12
oauth --> externalToken
sbose78 1d9bfd1
fix comment, and add nil check
sbose78 e9c93e6
fix test
sbose78 37b3c4a
check error before response nil
sbose78 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package auth | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"net/url" | ||
|
||
"fmt" | ||
|
||
"github.com/fabric8-services/fabric8-notification/auth/api" | ||
"github.com/fabric8-services/fabric8-wit/goasupport" | ||
goaclient "github.com/goadesign/goa/client" | ||
"github.com/goadesign/goa/uuid" | ||
"github.com/gregjones/httpcache" | ||
) | ||
|
||
func NewCachedClient(hostURL string) (*api.Client, error) { | ||
|
||
u, err := url.Parse(hostURL) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
tp := httpcache.NewMemoryCacheTransport() | ||
client := http.Client{Transport: tp} | ||
|
||
c := api.New(goaclient.HTTPClientDoer(&client)) | ||
c.Host = u.Host | ||
c.Scheme = u.Scheme | ||
return c, nil | ||
} | ||
|
||
func GetUser(ctx context.Context, client *api.Client, uID uuid.UUID) (*api.User, error) { | ||
resp, err := client.ShowUsers(goasupport.ForwardContextRequestID(ctx), api.ShowUsersPath(uID.String()), nil, nil) | ||
if resp != nil { | ||
defer resp.Body.Close() | ||
} | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
return nil, fmt.Errorf("non %v status code for %v, returned %v", http.StatusOK, "GET user", resp.StatusCode) | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
return client.DecodeUser(resp) | ||
} | ||
|
||
func GetSpaceCollaborators(ctx context.Context, client *api.Client, spaceID uuid.UUID) (*api.UserList, error) { | ||
pageLimit := 100 | ||
pageOffset := "0" | ||
resp, err := client.ListCollaborators(goasupport.ForwardContextRequestID(ctx), api.ListCollaboratorsPath(spaceID), &pageLimit, &pageOffset, nil, nil) | ||
if resp != nil { | ||
defer resp.Body.Close() | ||
} | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
return nil, fmt.Errorf("non %v status code for %v, returned %v", http.StatusOK, "GET collaborators", resp.StatusCode) | ||
} | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
return client.DecodeUserList(resp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ package: github.com/fabric8-services/fabric8-notification | |
license: Apache-2.0 | ||
import: | ||
- package: github.com/fabric8-services/fabric8-wit | ||
version: 58db841e76891f1251bdec86908c61360f11d375 | ||
version: ff1746954f6c1a89dc2c35b72731e19b63d842d2 | ||
subpackages: | ||
- log | ||
- errors | ||
|
@@ -11,6 +11,10 @@ import: | |
- jsonapi | ||
- design | ||
- goasupport | ||
- package: github.com/fabric8-services/fabric8-auth | ||
version: f67317193c3108895f853f80f9330c1a65b11004 | ||
subpackages: | ||
- design | ||
- package: github.com/gregjones/httpcache | ||
- package: github.com/mattbaird/gochimp | ||
- package: github.com/goadesign/goa | ||
|
@@ -34,7 +38,7 @@ import: | |
- package: github.com/zach-klippenstein/goregen | ||
- package: github.com/spf13/cobra | ||
- package: github.com/spf13/viper | ||
- package: github.com/Sirupsen/logrus | ||
- package: github.com/sirupsen/logrus | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed because of fabric8-services/fabric8-auth@468d4e6 |
||
- package: github.com/lib/pq | ||
- package: gopkg.in/yaml.v2 | ||
- package: github.com/jteeuwen/go-bindata | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resp can be nil here. Check err first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
37b3c4a , done.
had misunderstood your comment here initially.