mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	https://linear.app/unleash/issue/2-1155/refactor-permissions - Our `rbac-middleware` now supports multiple OR permissions; - Drops non-specific permissions (e.g. CRUD API token permissions without specifying the token type); - Makes our permission descriptions consistent; - Drops our higher-level permissions that basically mean ADMIN (e.g. ADMIN token permissions) in favor of `ADMIN` permission in order to avoid privilege escalations; This PR may help with https://linear.app/unleash/issue/2-1144/discover-potential-privilege-escalations as it may prevent privilege escalations altogether. There's some UI permission logic around this, but in the future https://linear.app/unleash/issue/2-1156/adapt-api-tokens-creation-ui-to-new-permissions could take it a bit further by adapting the creation of tokens as well. --------- Co-authored-by: Gastón Fournier <gaston@getunleash.io>
		
			
				
	
	
		
			22 lines
		
	
	
		
			472 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			472 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import React from 'react';
 | |
| 
 | |
| export interface IAccessContext {
 | |
|     isAdmin: boolean;
 | |
|     hasAccess: (
 | |
|         permission: string | string[],
 | |
|         project?: string,
 | |
|         environment?: string
 | |
|     ) => boolean;
 | |
| }
 | |
| 
 | |
| const hasAccessPlaceholder = () => {
 | |
|     throw new Error('hasAccess called outside AccessContext');
 | |
| };
 | |
| 
 | |
| const AccessContext = React.createContext<IAccessContext>({
 | |
|     isAdmin: false,
 | |
|     hasAccess: hasAccessPlaceholder,
 | |
| });
 | |
| 
 | |
| export default AccessContext;
 |