Compare commits
15 Commits
0.1.0-beta
...
0.1.0-beta
Author | SHA1 | Date | |
---|---|---|---|
![]() |
17777b111d | ||
![]() |
c7494a0bca | ||
![]() |
e23d6f92e5 | ||
![]() |
585091fefb | ||
![]() |
eabd88718d | ||
![]() |
072cd46809 | ||
![]() |
17676fa13b | ||
![]() |
8b510ed556 | ||
![]() |
3ac0b44446 | ||
![]() |
b1dd6f2c3b | ||
![]() |
f5ea94f63c | ||
![]() |
653befc737 | ||
![]() |
6fed439ec2 | ||
![]() |
5bd6fa5bc9 | ||
![]() |
75709e9f48 |
8
.github/workflows/release.yaml
vendored
8
.github/workflows/release.yaml
vendored
@@ -52,21 +52,23 @@ jobs:
|
|||||||
github-assets-uploader -f authorizer-${VERSION}-windows-amd64.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \
|
github-assets-uploader -f authorizer-${VERSION}-windows-amd64.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \
|
||||||
github-assets-uploader -f authorizer-${VERSION}-linux-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
|
github-assets-uploader -f authorizer-${VERSION}-linux-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
uses: docker/metadata-action@v3
|
||||||
with:
|
with:
|
||||||
images: lakhansamani/authorizer
|
images: lakhansamani/authorizer
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
build-args:
|
||||||
|
- VERSION=${{ basename ${GITHUB_REF}) }}
|
||||||
|
@@ -3,9 +3,10 @@ WORKDIR /app
|
|||||||
COPY server server
|
COPY server server
|
||||||
COPY Makefile .
|
COPY Makefile .
|
||||||
|
|
||||||
ARG VERSION=0.1.0-beta.0
|
ARG VERSION="latest"
|
||||||
ENV VERSION="${VERSION}"
|
ENV VERSION="$VERSION"
|
||||||
|
|
||||||
|
RUN echo "$VERSION"
|
||||||
RUN apk add build-base &&\
|
RUN apk add build-base &&\
|
||||||
make clean && make && \
|
make clean && make && \
|
||||||
chmod 777 build/server
|
chmod 777 build/server
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
30
app/package-lock.json
generated
30
app/package-lock.json
generated
@@ -8,7 +8,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@authorizerdev/authorizer-react": "^0.1.0-beta.16",
|
"@authorizerdev/authorizer-react": "^0.1.0-beta.18",
|
||||||
"@types/react": "^17.0.15",
|
"@types/react": "^17.0.15",
|
||||||
"@types/react-dom": "^17.0.9",
|
"@types/react-dom": "^17.0.9",
|
||||||
"esbuild": "^0.12.17",
|
"esbuild": "^0.12.17",
|
||||||
@@ -22,9 +22,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@authorizerdev/authorizer-js": {
|
"node_modules/@authorizerdev/authorizer-js": {
|
||||||
"version": "0.1.0-beta.16",
|
"version": "0.1.0-beta.19",
|
||||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-js/-/authorizer-js-0.1.0-beta.16.tgz",
|
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-js/-/authorizer-js-0.1.0-beta.19.tgz",
|
||||||
"integrity": "sha512-RyjWhVbLYvmkcAT+2ddpRhrt7P5DBVKtGKjHWRugSqenTW7XFQMlhQqx5Z09DeqLw3Lsq0VVZ5h8tWcExHvwEw==",
|
"integrity": "sha512-//uYjklwQfQKqLJHMAyjdrzh2nz6DycB3lEgl6bTXxmSbrz+l1kQyxB3y8wP/W30IrBQz8bZb+1sau+LD/FU7g==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-fetch": "^2.6.1"
|
"node-fetch": "^2.6.1"
|
||||||
},
|
},
|
||||||
@@ -33,11 +33,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@authorizerdev/authorizer-react": {
|
"node_modules/@authorizerdev/authorizer-react": {
|
||||||
"version": "0.1.0-beta.16",
|
"version": "0.1.0-beta.18",
|
||||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.1.0-beta.16.tgz",
|
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.1.0-beta.18.tgz",
|
||||||
"integrity": "sha512-b00LH0gtfMh/opFaGDF+EkxDOpNkCj/TNVjyW2wbiOFdC4HgLhc+UbPgL5/rDDol4XQsToL3SmwxmSxB2lWWuQ==",
|
"integrity": "sha512-lRWWlS9akZwwINRW1NatsbMob06NXht3HXNTUTlu1s8m1YjxmFRE/AL6UIplzAYTpR6eDWMxEEaS0qAVxovUcg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@authorizerdev/authorizer-js": "^0.1.0-beta.16",
|
"@authorizerdev/authorizer-js": "^0.1.0-beta.19",
|
||||||
"final-form": "^4.20.2",
|
"final-form": "^4.20.2",
|
||||||
"react-final-form": "^6.5.3",
|
"react-final-form": "^6.5.3",
|
||||||
"styled-components": "^5.3.0"
|
"styled-components": "^5.3.0"
|
||||||
@@ -797,19 +797,19 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@authorizerdev/authorizer-js": {
|
"@authorizerdev/authorizer-js": {
|
||||||
"version": "0.1.0-beta.16",
|
"version": "0.1.0-beta.19",
|
||||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-js/-/authorizer-js-0.1.0-beta.16.tgz",
|
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-js/-/authorizer-js-0.1.0-beta.19.tgz",
|
||||||
"integrity": "sha512-RyjWhVbLYvmkcAT+2ddpRhrt7P5DBVKtGKjHWRugSqenTW7XFQMlhQqx5Z09DeqLw3Lsq0VVZ5h8tWcExHvwEw==",
|
"integrity": "sha512-//uYjklwQfQKqLJHMAyjdrzh2nz6DycB3lEgl6bTXxmSbrz+l1kQyxB3y8wP/W30IrBQz8bZb+1sau+LD/FU7g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"node-fetch": "^2.6.1"
|
"node-fetch": "^2.6.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@authorizerdev/authorizer-react": {
|
"@authorizerdev/authorizer-react": {
|
||||||
"version": "0.1.0-beta.16",
|
"version": "0.1.0-beta.18",
|
||||||
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.1.0-beta.16.tgz",
|
"resolved": "https://registry.npmjs.org/@authorizerdev/authorizer-react/-/authorizer-react-0.1.0-beta.18.tgz",
|
||||||
"integrity": "sha512-b00LH0gtfMh/opFaGDF+EkxDOpNkCj/TNVjyW2wbiOFdC4HgLhc+UbPgL5/rDDol4XQsToL3SmwxmSxB2lWWuQ==",
|
"integrity": "sha512-lRWWlS9akZwwINRW1NatsbMob06NXht3HXNTUTlu1s8m1YjxmFRE/AL6UIplzAYTpR6eDWMxEEaS0qAVxovUcg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@authorizerdev/authorizer-js": "^0.1.0-beta.16",
|
"@authorizerdev/authorizer-js": "^0.1.0-beta.19",
|
||||||
"final-form": "^4.20.2",
|
"final-form": "^4.20.2",
|
||||||
"react-final-form": "^6.5.3",
|
"react-final-form": "^6.5.3",
|
||||||
"styled-components": "^5.3.0"
|
"styled-components": "^5.3.0"
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
"author": "Lakhan Samani",
|
"author": "Lakhan Samani",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@authorizerdev/authorizer-react": "^0.1.0-beta.16",
|
"@authorizerdev/authorizer-react": "^0.1.0-beta.18",
|
||||||
"@types/react": "^17.0.15",
|
"@types/react": "^17.0.15",
|
||||||
"@types/react-dom": "^17.0.9",
|
"@types/react-dom": "^17.0.9",
|
||||||
"esbuild": "^0.12.17",
|
"esbuild": "^0.12.17",
|
||||||
|
@@ -13,7 +13,6 @@ var (
|
|||||||
JWT_TYPE = ""
|
JWT_TYPE = ""
|
||||||
JWT_SECRET = ""
|
JWT_SECRET = ""
|
||||||
ALLOWED_ORIGINS = []string{}
|
ALLOWED_ORIGINS = []string{}
|
||||||
ALLOWED_CALLBACK_URLS = []string{}
|
|
||||||
AUTHORIZER_URL = ""
|
AUTHORIZER_URL = ""
|
||||||
PORT = "8080"
|
PORT = "8080"
|
||||||
REDIS_URL = ""
|
REDIS_URL = ""
|
||||||
|
@@ -11,43 +11,33 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// build variables
|
// build variables
|
||||||
var Version string
|
var (
|
||||||
|
Version string
|
||||||
// ParseArgs -> to parse the cli flag and get db url. This is useful with heroku button
|
ARG_DB_URL *string
|
||||||
func ParseArgs() {
|
ARG_DB_TYPE *string
|
||||||
dbURL := flag.String("database_url", "", "Database connection string")
|
ARG_AUTHORIZER_URL *string
|
||||||
dbType := flag.String("databse_type", "", "Database type, possible values are postgres,mysql,sqlite")
|
ARG_ENV_FILE *string
|
||||||
authorizerURL := flag.String("authorizer_url", "", "URL for authorizer instance, eg: https://xyz.herokuapp.com")
|
)
|
||||||
|
|
||||||
flag.Parse()
|
|
||||||
if *dbURL != "" {
|
|
||||||
constants.DATABASE_URL = *dbURL
|
|
||||||
}
|
|
||||||
|
|
||||||
if *dbType != "" {
|
|
||||||
constants.DATABASE_TYPE = *dbType
|
|
||||||
}
|
|
||||||
|
|
||||||
if *authorizerURL != "" {
|
|
||||||
constants.AUTHORIZER_URL = *authorizerURL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitEnv -> to initialize env and through error if required env are not present
|
// InitEnv -> to initialize env and through error if required env are not present
|
||||||
func InitEnv() {
|
func InitEnv() {
|
||||||
envPath := `.env`
|
envPath := `.env`
|
||||||
envFile := flag.String("env_file", "", "Env file path")
|
ARG_DB_URL = flag.String("database_url", "", "Database connection string")
|
||||||
|
ARG_DB_TYPE = flag.String("database_type", "", "Database type, possible values are postgres,mysql,sqlite")
|
||||||
|
ARG_AUTHORIZER_URL = flag.String("authorizer_url", "", "URL for authorizer instance, eg: https://xyz.herokuapp.com")
|
||||||
|
ARG_ENV_FILE = flag.String("env_file", "", "Env file path")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *envFile != "" {
|
if *ARG_ENV_FILE != "" {
|
||||||
envPath = *envFile
|
envPath = *ARG_ENV_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
err := godotenv.Load(envPath)
|
err := godotenv.Load(envPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error loading .env file")
|
log.Println("Error loading .env file")
|
||||||
}
|
}
|
||||||
|
|
||||||
constants.VERSION = Version
|
constants.VERSION = Version
|
||||||
|
|
||||||
constants.ADMIN_SECRET = os.Getenv("ADMIN_SECRET")
|
constants.ADMIN_SECRET = os.Getenv("ADMIN_SECRET")
|
||||||
constants.ENV = os.Getenv("ENV")
|
constants.ENV = os.Getenv("ENV")
|
||||||
constants.DATABASE_TYPE = os.Getenv("DATABASE_TYPE")
|
constants.DATABASE_TYPE = os.Getenv("DATABASE_TYPE")
|
||||||
@@ -104,20 +94,18 @@ func InitEnv() {
|
|||||||
}
|
}
|
||||||
constants.ALLOWED_ORIGINS = allowedOrigins
|
constants.ALLOWED_ORIGINS = allowedOrigins
|
||||||
|
|
||||||
allowedCallbackSplit := strings.Split(os.Getenv("ALLOWED_CALLBACK_URLS"), ",")
|
if *ARG_AUTHORIZER_URL != "" {
|
||||||
allowedCallbacks := []string{}
|
constants.AUTHORIZER_URL = *ARG_AUTHORIZER_URL
|
||||||
for _, val := range allowedCallbackSplit {
|
}
|
||||||
trimVal := strings.TrimSpace(val)
|
|
||||||
if trimVal != "" {
|
if *ARG_DB_URL != "" {
|
||||||
allowedCallbacks = append(allowedCallbacks, trimVal)
|
constants.DATABASE_URL = *ARG_DB_URL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *ARG_DB_TYPE != "" {
|
||||||
|
constants.DATABASE_TYPE = *ARG_DB_TYPE
|
||||||
}
|
}
|
||||||
if len(allowedCallbackSplit) == 0 {
|
|
||||||
allowedCallbackSplit = []string{"*"}
|
|
||||||
}
|
|
||||||
constants.ALLOWED_CALLBACK_URLS = allowedCallbackSplit
|
|
||||||
|
|
||||||
ParseArgs()
|
|
||||||
if constants.DATABASE_URL == "" {
|
if constants.DATABASE_URL == "" {
|
||||||
panic("Database url is required")
|
panic("Database url is required")
|
||||||
}
|
}
|
||||||
|
@@ -36,8 +36,8 @@ func Token(ctx context.Context, role *string) (*model.AuthResponse, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if role != nil && role != &claimRole {
|
if role != nil && *role != claimRole {
|
||||||
return res, fmt.Errorf(`unauthorized. invalid role for a given token`)
|
return res, fmt.Errorf(`unauthorized`)
|
||||||
}
|
}
|
||||||
|
|
||||||
userIdStr := fmt.Sprintf("%v", user.ID)
|
userIdStr := fmt.Sprintf("%v", user.ID)
|
||||||
|
Reference in New Issue
Block a user