Ticket #1036 (closed enhancement: fixed)

Opened 1 year ago

Last modified 6 months ago

core: Token based trusted auth

Reported by: rambo Assigned to: piotras
Priority: blocker Milestone: 9.09 Mjolnir
Component: Midgard Core Version: 9.03 Vinland
Keywords: Cc:

Description

As discussed in Linköping:

"trusted auth" is enabled in configuration by configuring tokens (which are just strings), there are two classes of token, one that allows only normal users and one that allows also admin users.

It would probably be clearer to have two separate auth methods for trusted and normal auth, I propose midgard_user::auth_trusted(string $username, string $token).

When the method is called it checks the configuration whether the given token is defined, then checks whether the user exists and finally checks if the user is admin and whether the token has admin logins enabled.

Return values as with normal password based login.

I don't know how exactly the config files are parsed but in Linköping I suggested the following logical structure:

  • trusted_auth
    • tokens
      • "rueytrie12314"
        • admin=false (default)
      • "9898rgdjklgdjkl"
        • admin=true

The components that need trusted auth will have to have configuration option for specifying the token to use, in general users should configure different tokens for different components to use but that's entirely optional (however it's exceedingly unwise to use admin enabled tokens with something like the facebook connector)

Change History

04/01/09 11:33:20 changed by rambo

See also #1037.

04/01/09 11:35:03 changed by rambo

  • component changed from MidCOM component to Midgard Core.

04/01/09 11:40:14 changed by piotras

  • priority changed from major to blocker.

(follow-up: ↓ 5 ) 04/01/09 11:54:48 changed by indeyets

1) why using only single "bit" for token-variants? I think using string-values makes more sense. Something like class=reader, class=user, class=admin.

so, API will look like this: mgd_user::auth($username, $password, $class='user')

2) wouldn't it be better to use opaque type as token? this way, it would be possible to use structure/object as token (while keeping serialization behind the scene)

(in reply to: ↑ 4 ) 04/01/09 17:37:37 changed by piotras

Replying to indeyets:

1) why using only single "bit" for token-variants? I think using string-values makes more sense. Something like class=reader, class=user, class=admin.

This is trusted auth so there should be fallback ACL anyway.

2) wouldn't it be better to use opaque type as token? this way, it would be possible to use structure/object as token (while keeping serialization behind the scene)

Yes, I like this idea. Though, there are few issues:

  • token should be an instance, not a structure (this is obvious, neither PHP nor Python has structures )
  • In some cases token instance shouldn't be available on user level, which means configuration file is the best place to initialize it

(follow-up: ↓ 8 ) 04/15/09 12:53:18 changed by piotras

  • milestone changed from 9.03 Vinland to 9.03.1 Vinland.

04/15/09 20:53:05 changed by piotras

(in reply to: ↑ 6 ) 04/24/09 12:03:24 changed by rambo

Replying to piotras:

1) why using only single "bit" for token-variants? I think using string-values makes more sense. Something like class=reader, class=user, class=admin.

This is trusted auth so there should be fallback ACL anyway.

Just to clarify: the bit does not specify what privileges you get with the token, it only specifies whether this token is usable for an user that has Midgard level admin privileges (ie: is member of the group that is the sitegroups admingroup).

So if the token does not have admin bit set and you try to use it to log in an user that has full admin privileges then the auth method will return failure, for normal user (with any other privileges than full admin) it works the same.

The actual privileges in any case come from the user that will be logged in.

06/11/09 18:22:25 changed by piotras

  • milestone changed from 9.03.1 Vinland to 9.09 Mjolnir.

07/23/09 10:26:22 changed by piotras

08/11/09 18:00:51 changed by piotras

  • status changed from new to assigned.

09/08/09 21:25:39 changed by piotras

Added group of MidgardKeyConfig? classes in r23314 and r23315

09/10/09 14:53:20 changed by piotras

(In [23338]) Try to create string array which holds found configuration files. Refs #1036

09/10/09 21:58:26 changed by piotras

(In [23340]) Use parent's protected property. Refs #1036

09/12/09 11:39:16 changed by piotras

(In [23341]) Use mcfg suffixed files. MidgardKeyConfigFile? declared not abstract. Refs #1036

09/12/09 11:40:35 changed by piotras

(In [23342]) Update autogenerated (including manual changes in key_config_file). Refs #1036

09/12/09 11:41:19 changed by piotras

(In [23343]) Compile key_config files. Refs #1036

09/12/09 11:42:49 changed by piotras

(In [23344]) Initial bindings. Refs #1036

09/12/09 11:43:42 changed by piotras

(In [23345]) Include key_config classes in builds. Refs #1036

09/17/09 08:59:44 changed by piotras

(In [23406]) Do not increase number of returned list twice. Refs #1036

09/23/09 12:24:39 changed by piotras

(In [23456]) Added KeyConfigContextError? domain. Constructor throws exception and propagates it via GError. Refs #1036

09/23/09 12:27:29 changed by piotras

(In [23457]) KeyConfigFile?(Context) example. Initial. Refs #1036

09/23/09 13:53:28 changed by piotras

(In [23459]) Initial. Example for token based authentication. Refs #1036

09/23/09 14:23:50 changed by piotras

(In [23460]) Added explicit construct method. Refs #1036

09/23/09 14:48:08 changed by piotras

(In [23461]) Get active class name in static get() method. Workaround. Refs #1036

09/23/09 14:52:38 changed by piotras

(In [23463]) Added explicit get method. Workaround. Refs #1036

09/23/09 19:37:30 changed by piotras

(In [23468]) Changed constructor which accepts optional properties array. Refs #1036.

09/23/09 20:28:43 changed by piotras

(In [23469]) Constructor accepts optional properties array argument. Refs #1036

09/23/09 21:44:58 changed by piotras

(In [23472]) Ensure GKeyFile has particular key before trying to get its value. Safe way to avoid G_KEY_FILE_ERROR_KEY_NOT_FOUND error on user level. Refs #1036

09/30/09 14:19:47 changed by piotras

(In [23523]) set_cfgs: Do not check suffix twice. Refs #1036

09/30/09 15:24:25 changed by piotras

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [23527]) Added MidgardKeyConfig? classes. Fixes #1036