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
Added changes required for dex setup for litmus 3.0.0-beta11 #4163
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
83b875c
Added changes required for dex setup
Saranya-jena e4f10f4
Moved dex-server to chaoscenter
Saranya-jena 89dfd01
resolved review comments
Saranya-jena e42e4d4
Merge branch 'master' of https://github.com/litmuschaos/litmus into d…
Saranya-jena 5845976
fixed imports
Saranya-jena File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package rest | |
|
||
import ( | ||
"context" | ||
"github.com/google/uuid" | ||
"net/http" | ||
"time" | ||
|
||
|
@@ -122,6 +123,54 @@ func DexCallback(userService services.ApplicationService) gin.HandlerFunc { | |
c.JSON(utils.ErrorStatusCodes[utils.ErrServerError], presenter.CreateErrorResponse(utils.ErrServerError)) | ||
return | ||
} | ||
c.Redirect(http.StatusPermanentRedirect, "/login?jwtToken="+jwtToken) | ||
|
||
var defaultProject string | ||
ownerProjects, err := userService.GetOwnerProjectIDs(c, signedInUser.ID) | ||
|
||
if len(ownerProjects) > 0 { | ||
defaultProject = ownerProjects[0].ID | ||
} else { | ||
// Adding user as project owner in project's member list | ||
newMember := &entities.Member{ | ||
UserID: signedInUser.ID, | ||
Role: entities.RoleOwner, | ||
Invitation: entities.AcceptedInvitation, | ||
Username: signedInUser.Username, | ||
Name: signedInUser.Name, | ||
Email: signedInUser.Email, | ||
JoinedAt: time.Now().Unix(), | ||
} | ||
var members []*entities.Member | ||
members = append(members, newMember) | ||
state := "active" | ||
newProject := &entities.Project{ | ||
ID: uuid.Must(uuid.NewRandom()).String(), | ||
Name: signedInUser.Username + "'s project", | ||
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. Replace name with |
||
Members: members, | ||
State: &state, | ||
Audit: entities.Audit{ | ||
IsRemoved: false, | ||
CreatedAt: time.Now().Unix(), | ||
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. Please use UnixMilli instead of Unix in all the places |
||
CreatedBy: entities.UserDetailResponse{ | ||
Username: signedInUser.Username, | ||
UserID: signedInUser.ID, | ||
Email: signedInUser.Email, | ||
}, | ||
UpdatedAt: time.Now().Unix(), | ||
UpdatedBy: entities.UserDetailResponse{ | ||
Username: signedInUser.Username, | ||
UserID: signedInUser.ID, | ||
Email: signedInUser.Email, | ||
}, | ||
}, | ||
} | ||
err := userService.CreateProject(newProject) | ||
if err != nil { | ||
return | ||
} | ||
defaultProject = newProject.ID | ||
} | ||
|
||
c.Redirect(http.StatusPermanentRedirect, "/login?jwtToken="+jwtToken+"&projectID="+defaultProject+"&projectRole="+string(entities.RoleOwner)) | ||
} | ||
} |
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,3 @@ | ||
FROM ghcr.io/dexidp/dex:latest | ||
ENV DEX_FRONTEND_DIR=/srv/dex/web | ||
COPY --chown=root:root web /srv/dex/web |
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,139 @@ | ||
# ConfigMap for DexServer | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: dex-server-admin-config | ||
namespace: litmus | ||
data: | ||
config.yaml: | | ||
issuer: http://<Your Domain>:32000 # Replace your domain here | ||
|
||
storage: | ||
type: kubernetes | ||
config: | ||
inCluster: true | ||
|
||
web: | ||
http: 0.0.0.0:5556 | ||
|
||
staticClients: | ||
- id: LitmusPortalAuthBackend | ||
redirectURIs: | ||
- '/auth/dex/callback' | ||
- 'http://localhost:8080/auth/dex/callback' # Included for local testing purposes | ||
name: 'LitmusPortalAuthBackend' | ||
secret: ZXhhbXBsZS1hcHAtc2VjcmV0 | ||
|
||
oauth2: | ||
skipApprovalScreen: true | ||
|
||
connectors: | ||
- type: google | ||
id: google | ||
name: Google | ||
config: | ||
clientID: # Add your Google Client ID here | ||
clientSecret: # Add your Google Client Secret here | ||
redirectURI: http://<Your Domain>:32000 # Replace your domain here | ||
|
||
- type: github | ||
id: github | ||
name: GitHub | ||
config: | ||
clientID: # Add your GitHub Client ID here | ||
clientSecret: # Add your GitHub Client Secret here | ||
redirectURI: http://<Your Domain>:32000/callback # Replace your domain here | ||
|
||
--- | ||
# ClusterRole for DexServer | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: litmus-dex-server | ||
rules: | ||
- apiGroups: [dex.coreos.com] | ||
resources: | ||
[ | ||
authcodes, | ||
authrequests, | ||
connectors, | ||
devicerequests, | ||
connectors, | ||
devicerequests, | ||
devicetokens, | ||
oauth2clients, | ||
offlinesessionses, | ||
passwords, | ||
refreshtokens, | ||
signingkeies, | ||
] | ||
verbs: [delete, deletecollection, get, list, patch, create, update, watch] | ||
--- | ||
# ClusterRoleBinding for DexServer | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: litmus-dex-server-crb | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: litmus-dex-server | ||
subjects: | ||
- kind: ServiceAccount | ||
name: litmus-server-account | ||
namespace: litmus | ||
--- | ||
# Deployment for DexServer | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: litmusportal-dex-server | ||
namespace: litmus | ||
labels: | ||
component: litmusportal-dex-server | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
component: litmusportal-dex-server | ||
template: | ||
metadata: | ||
labels: | ||
component: litmusportal-dex-server | ||
spec: | ||
serviceAccountName: litmus-server-account | ||
containers: | ||
- name: litmus-dex | ||
imagePullPolicy: IfNotPresent | ||
image: litmuschaos/litmusportal-dex-server:ci | ||
command: ["/usr/local/bin/dex", "serve", "/etc/dex/cfg/config.yaml"] | ||
ports: | ||
- containerPort: 5556 | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/dex/cfg | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: dex-server-admin-config | ||
items: | ||
- key: config.yaml | ||
path: config.yaml | ||
--- | ||
# Exposed service for DexServer | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: litmusportal-dex-service | ||
namespace: litmus | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: dex-server | ||
port: 80 | ||
protocol: TCP | ||
targetPort: 5556 | ||
nodePort: 32000 | ||
selector: | ||
component: litmusportal-dex-server |
17 changes: 17 additions & 0 deletions
17
chaoscenter/dex-server/web/static/img/atlassian-crowd-icon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
Please convert it to UnixMilli()