Compare commits

...

8 Commits

Author SHA1 Message Date
Yang Luo
e841d0ba8e feat: fix /api/send-email API for app user 2024-01-07 21:11:22 +08:00
Yang Luo
e5a9594f90 Hide Google OneTap in iframe 2024-01-07 10:33:25 +08:00
Satinder Singh
c542929835 fix: add vscode local debugging support (#2585) 2024-01-07 09:26:33 +08:00
hsluoyz
86dea71efd ci: update helm index.yaml 2024-01-06 19:31:07 +00:00
Michael
9e536850fd feat(helm): support for extra volume mounts (#2584)
* feat(helm): support for extraVolumes and extraVolumeMounts

* ci(helm): run helm unittests
2024-01-07 03:30:44 +08:00
Michael
fddd4a12b8 chore: update helm version to v1.492.0 (#2582) 2024-01-07 00:14:53 +08:00
Yang Luo
2d6fae32be feat: support custom config path via "config" 2024-01-06 14:09:48 +08:00
Yang Luo
741cff99df Remove isCreateDatabaseDefined 2024-01-06 14:08:34 +08:00
13 changed files with 243 additions and 27 deletions

View File

@@ -5,7 +5,7 @@ on:
branches:
- master
paths:
- 'manifests/casdoor/Chart.yaml'
- "manifests/casdoor/**"
jobs:
release-helm-chart:
@@ -18,6 +18,12 @@ jobs:
- name: Set up Helm
uses: azure/setup-helm@v3
- name: Run helm unittest
id: unittest
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git
helm unittest manifests/casdoor
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
@@ -37,4 +43,4 @@ jobs:
- name: Commit updated helm index.yaml
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'ci: update helm index.yaml'
commit_message: "ci: update helm index.yaml"

5
.gitignore vendored
View File

@@ -18,7 +18,7 @@ bin/
.idea/
*.iml
.vscode/
.vscode/settings.json
tmp/
tmpFiles/
@@ -31,3 +31,6 @@ commentsRouter*.go
# ignore build result
casdoor
server
# include helm-chart
!manifests/casdoor

15
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"cwd": "${workspaceFolder}",
"debugAdapter": "dlv-dap",
"args": ["--createDatabase=true"]
}
]
}

View File

@@ -86,6 +86,9 @@ docker-build: ## Build docker image with the manager.
docker-push: ## Push docker image with the manager.
docker push ${REGISTRY}/${IMG}:${IMG_TAG}
deps: ## Run dependencies for local development
docker compose up -d db
lint-install: ## Install golangci-lint
@# The following installs a specific version of golangci-lint, which is appropriate for a CI server to avoid different results from build to build
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.40.1

View File

@@ -54,7 +54,7 @@ type NotificationForm struct {
// @Success 200 {object} controllers.Response The Response object
// @router /api/send-email [post]
func (c *ApiController) SendEmail() {
user, ok := c.RequireSignedInUser()
userId, ok := c.RequireSignedIn()
if !ok {
return
}
@@ -116,8 +116,17 @@ func (c *ApiController) SendEmail() {
// "You have requested a verification code at Casdoor. Here is your code: %s, please enter in 5 minutes."
content := strings.Replace(provider.Content, "%s", code, 1)
if user != nil {
content = strings.Replace(content, "%{user.friendlyName}", user.GetFriendlyName(), 1)
if !strings.HasPrefix(userId, "app/") {
var user *object.User
user, err = object.GetUser(userId)
if err != nil {
c.ResponseError(err.Error())
return
}
if user != nil {
content = strings.Replace(content, "%{user.friendlyName}", user.GetFriendlyName(), 1)
}
}
for _, receiver := range emailForm.Receivers {

View File

@@ -21,4 +21,4 @@ version: 0.3.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.18.0"
appVersion: "v1.492.0"

View File

@@ -0,0 +1,14 @@
apiVersion: v1
entries:
casdoor-helm-charts:
- apiVersion: v2
appVersion: v1.492.0
created: "2024-01-06T19:31:03.561298242Z"
description: A Helm chart for Kubernetes
digest: 164782e0dee310005588317160890465694aa17502765496cb796ec0778d9bfd
name: casdoor-helm-charts
type: application
urls:
- oci://registry-1.docker.io/casbin/casdoor-helm-charts-0.3.0.tgz
version: 0.3.0
generated: "2024-01-06T19:31:03.56073909Z"

View File

@@ -57,21 +57,27 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config-volume
mountPath: /conf
- name: config-volume
mountPath: /conf
{{- if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
{{ if .Values.extraContainersEnabled }}
{{- .Values.extraContainers | nindent 8 }}
{{- end }}
volumes:
- name: config-volume
projected:
defaultMode: 420
sources:
- configMap:
items:
- key: app.conf
path: app.conf
name: {{ printf "%s-config" (include "casdoor.fullname" .) }}
- name: config-volume
projected:
defaultMode: 420
sources:
- configMap:
name: {{ printf "%s-config" (include "casdoor.fullname" .) }}
items:
- key: app.conf
path: app.conf
{{- if .Values.extraVolumes }}
{{- toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}

View File

@@ -0,0 +1,128 @@
has extraVolume and extraVolumeMounts:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: casdoor-helm-charts
app.kubernetes.io/version: 1.2.3
helm.sh/chart: casdoor-helm-charts-1.0.0
name: RELEASE-NAME-casdoor-helm-charts
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: casdoor-helm-charts
template:
metadata:
annotations:
checksum/config: 529bc7ea51d30d00fefc46d24be7446d0637939827bccc1c3f03755f70059470
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: casdoor-helm-charts
spec:
containers:
- env:
- name: RUNNING_IN_DOCKER
value: "true"
image: casbin/casdoor:1.2.3
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /
port: http
name: casdoor-helm-charts
ports:
- containerPort: 8000
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /
port: http
resources: {}
securityContext: {}
volumeMounts:
- mountPath: /conf
name: config-volume
- mountPath: /extra-volume
name: extra-volume
securityContext: {}
serviceAccountName: RELEASE-NAME-casdoor-helm-charts
volumes:
- name: config-volume
projected:
defaultMode: 420
sources:
- configMap:
items:
- key: app.conf
path: app.conf
name: RELEASE-NAME-casdoor-helm-charts-config
- emptyDir: {}
name: extra-volume
manifest should match snapshot:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: casdoor-helm-charts
app.kubernetes.io/version: 1.2.3
helm.sh/chart: casdoor-helm-charts-1.0.0
name: RELEASE-NAME-casdoor-helm-charts
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: casdoor-helm-charts
template:
metadata:
annotations:
checksum/config: 529bc7ea51d30d00fefc46d24be7446d0637939827bccc1c3f03755f70059470
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: casdoor-helm-charts
spec:
containers:
- env:
- name: RUNNING_IN_DOCKER
value: "true"
image: casbin/casdoor:1.2.3
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /
port: http
name: casdoor-helm-charts
ports:
- containerPort: 8000
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /
port: http
resources: {}
securityContext: {}
volumeMounts:
- mountPath: /conf
name: config-volume
securityContext: {}
serviceAccountName: RELEASE-NAME-casdoor-helm-charts
volumes:
- name: config-volume
projected:
defaultMode: 420
sources:
- configMap:
items:
- key: app.conf
path: app.conf
name: RELEASE-NAME-casdoor-helm-charts-config

View File

@@ -0,0 +1,20 @@
suite: test deployment
templates:
- deployment.yaml
chart:
version: 1.0.0
appVersion: 1.2.3
tests:
- it: manifest should match snapshot
asserts:
- matchSnapshot: {}
- it: has extraVolume and extraVolumeMounts
set:
extraVolumes:
- name: extra-volume
emptyDir: {}
extraVolumeMounts:
- name: extra-volume
mountPath: /extra-volume
asserts:
- matchSnapshot: {}

View File

@@ -114,4 +114,6 @@ extraContainersEnabled: false
extraContainers: ""
# extraContainers: |
# - name: ...
# image: ...
# image: ...
extraVolumeMounts: []
extraVolumes: []

View File

@@ -36,16 +36,14 @@ import (
)
var (
ormer *Ormer = nil
isCreateDatabaseDefined = false
createDatabase = true
ormer *Ormer = nil
createDatabase = true
configPath = "conf/app.conf"
)
func InitFlag() {
if !isCreateDatabaseDefined {
isCreateDatabaseDefined = true
createDatabase = getCreateDatabaseFlag()
}
createDatabase = getCreateDatabaseFlag()
configPath = getConfigFlag()
}
func getCreateDatabaseFlag() bool {
@@ -54,6 +52,12 @@ func getCreateDatabaseFlag() bool {
return *res
}
func getConfigFlag() string {
res := flag.String("config", "conf/app.conf", "set it to \"/your/path/app.conf\" if your config file is not in: \"/conf/app.conf\"")
flag.Parse()
return *res
}
func InitConfig() {
err := beego.LoadAppConfig("ini", "../conf/app.conf")
if err != nil {
@@ -68,7 +72,7 @@ func InitConfig() {
func InitAdapter() {
if conf.GetConfigString("driverName") == "" {
if !util.FileExist("conf/app.conf") {
if !util.FileExist(configPath) {
dir, err := os.Getwd()
if err != nil {
panic(err)

View File

@@ -468,6 +468,10 @@ class LoginPage extends React.Component {
}
renderOtherFormProvider(application) {
if (Setting.inIframe()) {
return null;
}
for (const providerConf of application.providers) {
if (providerConf.provider?.type === "Google" && providerConf.rule === "OneTap" && this.props.preview !== "auto") {
return (
@@ -475,6 +479,8 @@ class LoginPage extends React.Component {
);
}
}
return null;
}
renderForm(application) {