-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from cthit/gamma-integration
Gamma integration
- Loading branch information
Showing
10 changed files
with
806 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
version: "3" | ||
services: | ||
gamma-db: | ||
image: postgres:10 | ||
environment: | ||
POSTGRES_USER: user | ||
POSTGRES_DB: postgres | ||
POSTGRES_PASSWORD: password | ||
|
||
gamma-frontend: | ||
image: cthit/gamma-frontend:development | ||
network_mode: host | ||
ports: | ||
- 3000:3000 | ||
|
||
gamma-backend: | ||
image: cthit/gamma-backend:latest | ||
environment: | ||
# Default admin user name = admin | ||
# Default admin password = password | ||
|
||
DB_USER: user | ||
DB_PASSWORD: password | ||
DB_HOST: gamma-db | ||
DB_PORT: 5432 | ||
DB_NAME: postgres | ||
|
||
REDIS_HOST: redis | ||
REDIS_PASSWORD: "" | ||
|
||
SERVER_PORT: 8081 | ||
FRONTEND_REDIRECT_URI: http://localhost:3000/login | ||
SUCCESSFUL_LOGIN: http://localhost:3000 | ||
CORS_ALLOWED_ORIGIN: http://localhost:3000 | ||
COOKIE_DOMAIN: localhost | ||
PRODUCTION: "false" | ||
IS_MOCKING_CLIENT: "true" | ||
DEFAULT_REDIRECT_URI: http://localhost:3001/callback | ||
|
||
ports: | ||
- 8081:8081 | ||
|
||
redis: | ||
image: redis:5.0 |
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 |
---|---|---|
|
@@ -6,6 +6,10 @@ | |
servicekeyfile = "gapps.json" | ||
adminaccount = "[email protected]" | ||
|
||
[gamma.producer] | ||
apiKey = "key" | ||
url = "http://localhost:8080" | ||
|
||
[ldap] | ||
url = "ldap.mydomain.ex:636" | ||
servername = "mydomain.ex" | ||
|
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,96 @@ | ||
package gamma | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
//Executes a generic get request to Gamma | ||
func gammaReq(s *GammaService, endpoint string, response interface{}) error { | ||
req, err := http.NewRequest("GET", fmt.Sprintf("%s%s", s.gammaUrl, endpoint), nil) | ||
if err != nil { | ||
log.Println(err) | ||
return err | ||
} | ||
|
||
req.Header.Set("Authorization", fmt.Sprintf("pre-shared %s", s.apiKey)) | ||
|
||
client := &http.Client{} | ||
resp, err := client.Do(req) | ||
if err != nil { | ||
log.Println(err) | ||
return err | ||
} | ||
|
||
body, err := ioutil.ReadAll(resp.Body) | ||
if err != nil { | ||
log.Println(err) | ||
return err | ||
} | ||
|
||
err = json.Unmarshal(body, &response) | ||
if err != nil { | ||
log.Println(err) | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
//Fetches all the fkit-groups from Gamma | ||
func getGammaGroups(s *GammaService) ([]FKITGroup, error) { | ||
var groups struct { | ||
Groups []FKITGroup `json:"groups"` | ||
} | ||
|
||
err := gammaReq(s, "/api/groups", &groups) | ||
if err != nil { | ||
log.Println(err) | ||
return nil, err | ||
} | ||
|
||
return groups.Groups, nil | ||
} | ||
|
||
//Fetches all super groups from Gamma | ||
func getSuperGroups(s *GammaService) ([]FKITSuperGroup, error) { | ||
var superGroups []FKITSuperGroup | ||
|
||
err := gammaReq(s, "/api/superGroups", &superGroups) | ||
if err != nil { | ||
log.Println(err) | ||
return nil, err | ||
} | ||
|
||
return superGroups, nil | ||
} | ||
|
||
//Fetches all posts which has a mail prefix | ||
func getMailPosts(s *GammaService) ([]Post, error) { | ||
posts := []Post{} | ||
err := gammaReq(s, "/api/groups/posts", &posts) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
mailPosts := []Post{} | ||
for _, post := range posts { | ||
if post.EmailPrefix != "" { | ||
mailPosts = append(mailPosts, post) | ||
} | ||
} | ||
|
||
return mailPosts, nil | ||
} | ||
|
||
//Fetches all active groups | ||
func getActiveGroups(s *GammaService) ([]FKITGroup, error) { | ||
groups := struct { | ||
GetFKITGroupResponse []FKITGroup `json:"getFKITGroupResponse"` | ||
}{} | ||
err := gammaReq(s, "/api/groups/active", &groups) | ||
return groups.GetFKITGroupResponse, err | ||
} |
Oops, something went wrong.