-
Notifications
You must be signed in to change notification settings - Fork 5
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
Auth0 user invite tickets #895
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
430ac31
send invite email on add collaborator
pdeziel 3b9cf17
Merge branch 'main' into sc-9509
pdeziel 4cfedf3
auth0 user invite tickets
pdeziel c916021
Merge branch 'main' into sc-9509
pdeziel 56327ad
fix lint error
pdeziel 7ff3ea1
Merge branch 'sc-9509' of github.com:trisacrypto/directory into sc-9509
pdeziel 2c9ab61
Merge branch 'main' into sc-9509
pdeziel ec74ca7
fix file formatting
pdeziel 9c4b198
update redirect URL in docker compose
pdeziel 2550789
Merge branch 'main' into sc-9509
pdeziel 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 |
---|---|---|
|
@@ -33,18 +33,20 @@ import ( | |
) | ||
|
||
const ( | ||
KeyID = "StyqeY8Kl4Eam28KsUs" | ||
ClientID = "a5laOSr0NOX1L53yBaNtumKOoExFxptc" | ||
ClientSecret = "me4JZSvBvPSnBaM0h0AoXgXPn1VBiBMz0bL7E/sV1isndP9lZ5ptm5NWA9IkKwEb" | ||
Audience = "http://localhost" | ||
Name = "Leopold Wentzel" | ||
Email = "[email protected]" | ||
UserID = "test|abcdefg1234567890" | ||
UserRole = "Organization Collaborator" | ||
OrgID = "b1b9e9b1-9a44-4317-aefa-473971b4df42" | ||
MainNetVASP = "87d92fd1-53cf-47d8-85b1-048e8a38ced9" | ||
TestNetVASP = "d0082f55-d3ba-4726-a46d-85e3f5a2911f" | ||
Scope = "openid profile email" | ||
KeyID = "StyqeY8Kl4Eam28KsUs" | ||
ClientID = "a5laOSr0NOX1L53yBaNtumKOoExFxptc" | ||
ClientSecret = "me4JZSvBvPSnBaM0h0AoXgXPn1VBiBMz0bL7E/sV1isndP9lZ5ptm5NWA9IkKwEb" | ||
Audience = "http://localhost" | ||
ConnectionName = "Username-Password-Authentication" | ||
RedirectURL = "https://localhost/auth/callback" | ||
Name = "Leopold Wentzel" | ||
Email = "[email protected]" | ||
UserID = "test|abcdefg1234567890" | ||
UserRole = "Organization Collaborator" | ||
OrgID = "b1b9e9b1-9a44-4317-aefa-473971b4df42" | ||
MainNetVASP = "87d92fd1-53cf-47d8-85b1-048e8a38ced9" | ||
TestNetVASP = "d0082f55-d3ba-4726-a46d-85e3f5a2911f" | ||
Scope = "openid profile email" | ||
) | ||
|
||
var ( | ||
|
@@ -116,6 +118,9 @@ func New() (s *Server, err error) { | |
s.mux.HandleFunc("/api/v2/users/"+UserID, s.Users) | ||
s.mux.HandleFunc("/api/v2/users/"+UserID+"/roles", s.UserRoles) | ||
s.mux.HandleFunc("/api/v2/roles", s.Roles) | ||
s.mux.HandleFunc("/api/v2/users-by-email", s.ListUsers) | ||
s.mux.HandleFunc("/api/v2/tickets/password-change", s.GenerateTicket) | ||
s.mux.HandleFunc("/api/v2/tickets/email-verification", s.GenerateTicket) | ||
|
||
s.srv = httptest.NewTLSServer(s.mux) | ||
s.URL, _ = url.Parse(s.srv.URL) | ||
|
@@ -125,12 +130,14 @@ func New() (s *Server, err error) { | |
// Config returns an AuthConfig that can be used to setup middleware. | ||
func (s *Server) Config() config.AuthConfig { | ||
return config.AuthConfig{ | ||
Domain: s.URL.Host, | ||
Audience: Audience, | ||
ProviderCache: 30 * time.Second, | ||
ClientID: ClientID, | ||
ClientSecret: ClientSecret, | ||
Testing: true, | ||
Domain: s.URL.Host, | ||
Audience: Audience, | ||
ConnectionName: ConnectionName, | ||
RedirectURL: RedirectURL, | ||
ProviderCache: 30 * time.Second, | ||
ClientID: ClientID, | ||
ClientSecret: ClientSecret, | ||
Testing: true, | ||
} | ||
} | ||
|
||
|
@@ -228,6 +235,8 @@ func (s *Server) Users(w http.ResponseWriter, r *http.Request) { | |
switch r.Method { | ||
case http.MethodGet: | ||
s.GetUser(w, r) | ||
case http.MethodPost: | ||
s.CreateUser(w, r) | ||
case http.MethodPatch: | ||
s.PatchUserAppMetadata(w, r) | ||
default: | ||
|
@@ -246,6 +255,22 @@ func (s *Server) GetUser(w http.ResponseWriter, r *http.Request) { | |
} | ||
} | ||
|
||
func (s *Server) CreateUser(w http.ResponseWriter, r *http.Request) { | ||
// Create a new user object | ||
user := &management.User{} | ||
if err := json.NewDecoder(r.Body).Decode(user); err != nil { | ||
w.WriteHeader(http.StatusBadRequest) | ||
return | ||
} | ||
|
||
// Add the user to the map | ||
id := UserID | ||
user.ID = &id | ||
s.users[*user.ID] = user | ||
|
||
w.WriteHeader(http.StatusCreated) | ||
} | ||
|
||
func (s *Server) UserRoles(w http.ResponseWriter, r *http.Request) { | ||
switch r.Method { | ||
case http.MethodGet: | ||
|
@@ -259,6 +284,20 @@ func (s *Server) UserRoles(w http.ResponseWriter, r *http.Request) { | |
} | ||
} | ||
|
||
func (s *Server) ListUsers(w http.ResponseWriter, r *http.Request) { | ||
switch r.Method { | ||
case http.MethodGet: | ||
users := make([]*management.User, 0) | ||
for _, user := range s.users { | ||
users = append(users, user) | ||
} | ||
w.Header().Add("Content-Type", "application/json") | ||
json.NewEncoder(w).Encode(users) | ||
default: | ||
w.WriteHeader(http.StatusMethodNotAllowed) | ||
} | ||
} | ||
|
||
func (s *Server) ListUserRoles(w http.ResponseWriter, r *http.Request) { | ||
// Return the roles object from the map | ||
// TODO: Parse the user id from the request | ||
|
@@ -270,6 +309,21 @@ func (s *Server) ListUserRoles(w http.ResponseWriter, r *http.Request) { | |
} | ||
} | ||
|
||
func (s *Server) GenerateTicket(w http.ResponseWriter, r *http.Request) { | ||
// Create a new ticket object | ||
ticket := &management.Ticket{} | ||
if err := json.NewDecoder(r.Body).Decode(ticket); err != nil { | ||
w.WriteHeader(http.StatusBadRequest) | ||
return | ||
} | ||
|
||
url := "https://example.com/tickets/1234" | ||
ticket.Ticket = &url | ||
|
||
w.Header().Add("Content-Type", "application/json") | ||
json.NewEncoder(w).Encode(ticket) | ||
} | ||
|
||
type RoleParams struct { | ||
Roles []string `json:"roles"` | ||
} | ||
|
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
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.
Added these methods so the Auth0 management API doesn't error on us during tests.