Utilities¶
Magpie CLI Helpers¶
Multiple CLI helpers are provided. These consist mostly of setup operation scripts that are automatically executed
during Magpie startup. Additional common functions are also provided such as registering service providers from a
configuration file or creating basic user accounts. Please refer to their corresponding usage by calling them with
--help
argument for more details.
Available helpers:
Command |
Description |
---|---|
|
Register or unregister users using entries provided by batch file or arguments. |
|
Register default users and groups for Magpie internal operation.
See Configuration for details on applicable parameters definitions.
|
|
Register service providers from a configuration file.
This is the same command executed at Magpie startup using files defined through configuration settings.
|
|
Run any required database migration operation, according to detected database state and required one by
the current Magpie version.
This operation is the same command that is executed at Magpie startup to ensure data integrity.
|
|
Synchronizes local and remote resources based on Magpie service’s
sync-type methodology.See also magpie-con.
|
For convenience, a generic CLI magpie_helper
is also provided which allows calling each of the other helper
operations as mode. You can therefore do as follows.
# list of available 'helper' commands
magpie_helper --help
# arguments of the given helper
magpie_helper [helper] --help
For example, the two statements below are equivalent.
magpie_helper register_providers [...]
# OR
magpie_register_providers [...]
When using an conda
environment, you should be able to directly call the magpie_helper
CLI as above if you
previously installed the package (see installation).
Source code of these helpers can be found here.
Magpie Connection¶
The repository Ouranosinc/requests-magpie offers basic Authentication connection to a running Magpie instance
similarly to how traditional HTTPBasicAuth
works under the hood. Using this, you can easily plug-and-play Magpie
in order to use it with the standard requests
library by passing auth=MagpieAuth(<...>)
.
Magpie Adapter: Integration with Twitcher¶
The class magpie.adapter.MagpieAdapter
(source) allows an easy integration with
the proxy service Twitcher. This allows the user to setup a server (i.e.: using docker-compose or similar) that
can easily integrate a complete user authentication and authorization chain by having Twitcher ask Magpie for
the targeted service/resource access permissions via the adapter upon receiving an HTTP(S) request.
On each new version build of the Magpie docker image, a corresponding docker image is built as
pavics/twitcher:magpie-<version>
with pre-configured adapter within Twitcher so that both can be used together.
Furthermore, when the above docker image is used with the integrated adapter, a new HTTP POST
request on route
/verify
is added to Twitcher. This method allows to test if an authentication token cookie generated by Magpie
(from login via API or UI) is valid and correctly interpreted by the Twitcher instance. This can be quite useful to
confirm that both instances were adequately configured as both require to share the same magpie.secret
configuration
(amongst many other settings) in order to lookup and authenticate users correctly from incoming HTTP requests.