Initialize the global authorization manager. Must be invoked at Feast server initialization time to create the `AuthManager` instance. Args: server_type: The server type. auth_type: The authorization manager type. Raises: ValueError: If any input argument h
(
server_type: ServerType, auth_type: AuthManagerType, auth_config: AuthConfig
)
| 85 | |
| 86 | |
| 87 | def init_auth_manager( |
| 88 | server_type: ServerType, auth_type: AuthManagerType, auth_config: AuthConfig |
| 89 | ): |
| 90 | """ |
| 91 | Initialize the global authorization manager. |
| 92 | Must be invoked at Feast server initialization time to create the `AuthManager` instance. |
| 93 | |
| 94 | Args: |
| 95 | server_type: The server type. |
| 96 | auth_type: The authorization manager type. |
| 97 | |
| 98 | Raises: |
| 99 | ValueError: If any input argument has an unmanaged value. |
| 100 | """ |
| 101 | if auth_type == AuthManagerType.NONE: |
| 102 | set_auth_manager(AllowAll()) |
| 103 | else: |
| 104 | token_extractor: TokenExtractor |
| 105 | token_parser: TokenParser |
| 106 | |
| 107 | if server_type == ServerType.REST: |
| 108 | token_extractor = RestTokenExtractor() |
| 109 | elif server_type == ServerType.ARROW: |
| 110 | token_extractor = ArrowFlightTokenExtractor() |
| 111 | elif server_type == ServerType.GRPC: |
| 112 | token_extractor = GrpcTokenExtractor() |
| 113 | else: |
| 114 | raise ValueError(f"Unmanaged server type {server_type}") |
| 115 | |
| 116 | if auth_type == AuthManagerType.KUBERNETES: |
| 117 | from feast.permissions.auth.kubernetes_token_parser import ( |
| 118 | KubernetesTokenParser, |
| 119 | ) |
| 120 | |
| 121 | token_parser = KubernetesTokenParser() |
| 122 | elif auth_type == AuthManagerType.OIDC: |
| 123 | assert isinstance(auth_config, OidcAuthConfig) |
| 124 | token_parser = OidcTokenParser(auth_config=auth_config) |
| 125 | else: |
| 126 | raise ValueError(f"Unmanaged authorization manager type {auth_type}") |
| 127 | |
| 128 | auth_manager = AuthManager( |
| 129 | token_extractor=token_extractor, token_parser=token_parser |
| 130 | ) |
| 131 | set_auth_manager(auth_manager) |
no test coverage detected