Skip to content

Commit

Permalink
feat(auth): add roles / permissions to auth package
Browse files Browse the repository at this point in the history
add roles and permissions (code driven) to auth package. update graphql schema to handle cases when
no team permissions are provided
  • Loading branch information
bahdcoder committed Sep 30, 2021
1 parent aa90300 commit 9ce722b
Show file tree
Hide file tree
Showing 14 changed files with 562 additions and 485 deletions.
7 changes: 3 additions & 4 deletions examples/typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
array,
hasMany,
belongsTo,
boolean
boolean,
route
} from '@tensei/core'

export default tensei()
Expand Down Expand Up @@ -59,7 +60,6 @@ export default tensei()
welcome(),
cms().plugin(),
auth()
.teams()
.verifyEmails()
.configureTokens({
accessTokenExpiresIn: 60,
Expand All @@ -81,8 +81,7 @@ export default tensei()
])
.db({
type: 'sqlite',
dbName: 'db.sqlite',
debug: true
dbName: 'db.sqlite'
})
.start()
.catch(console.error)
1 change: 1 addition & 0 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"files": [
"build/",
"auth.d.ts",
"teams.d.ts",
"auth.config.d.ts"
],
"types": "./build/index.d.ts",
Expand Down
6 changes: 2 additions & 4 deletions packages/auth/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AnyEntity } from '@mikro-orm/core'
import { UserRole } from '@tensei/common'
import { ApiContext } from '@tensei/common'
import { DataPayload } from '@tensei/common'
import { PermissionContract } from 'teams/Permission'
import { PermissionContract, RoleContract } from 'teams/Permission'

export interface GrantConfig {
key: string
Expand Down Expand Up @@ -57,15 +57,13 @@ export interface AuthPluginConfig {
teamResource: string
prefix: string
teamPermissions: PermissionContract[]
roles: RoleContract[]
autoFillUser: boolean
autoFilterForUser: boolean
excludedPathsFromCsrf: string[]
enableRefreshTokens?: boolean
registered?: (ctx: ApiContext) => Promise<void> | void
roleResource: string
permissionResource: string
teams: boolean
rolesAndPermissions: boolean
passwordResetResource: string
apiPath: string
tokensConfig: {
Expand Down
Loading

0 comments on commit 9ce722b

Please sign in to comment.