Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable basic auth file user store support #862

Assignees
Labels
Area/Security Issues related to stdlib security module/auth module/http Points/2 Type/Improvement Verson/SwanLakeDump All issues planned for Swan Lake GA release

Comments

@ldclakmal
Copy link
Member

ldclakmal commented Jan 21, 2021

Need to enable "basic auth file user store" support after Swan Lake alpha which was disabled due to a limitation of configurable feature does not support for mapping types.

This was disable by the PRs.

  1. Disable basic auth file user store support module-ballerina-auth#60
  2. Disable basic auth file user store support module-ballerina-http#183

Related PRs:

  1. Fix BBEs of access control category ballerina-distribution#1182
  2. Disable basic auth integration tests ballerina-distribution#1187
@sameerajayasoma
Copy link
Contributor

sameerajayasoma commented Feb 4, 2021

Is a mapping type the best choice for this use case? If you use a mapping value, the Config.toml would have the following bits. Here auth is the module name and users is the variable name of map type.

# 1) Inline table version
[auth.users]
alice = { password ="password1", scopes="scope1"}
bob = { password ="password2", scopes="scope1"}


# 2) Standard table version
[auth.users.alice]
password="password1"
scopes="scope1"

[auth.users.bob]
password="password2"
scopes="scope1"

How about using a Ballerina table here? I think following is better. WDYT @shafreenAnfar @ldclakmal ?

[[auth.users]]
username = "alice"
password="password1"
scopes="scope1"

[[auth.users]]
username = "bob"
password="password2"
scopes="scope1"

# With inline tables
[auth]
users = [ { username = "Alice", password ="password1", scopes="scope1"}, 
          { username = "Bob", password ="password2", scopes="scope1"} ]

Here is the Ballerina syntax:

type AuthInfo record {
 readonly string username;
 string password;
};

configurable table<AuthInfo> key(username) & readonly users = ?

@ldclakmal
Copy link
Member Author

ldclakmal commented Feb 5, 2021

Yes. I am +1 for the Ballerina table representation of the TOML file.

IMO, it would be better to support the scopes as an optional array field also, which will end-up the Ballerina syntax as:

type AuthInfo record {
  readonly string username;
  string password;
  string[] scopes?;
};

configurable table<AuthInfo> key(username) & readonly users = ?

@ldclakmal
Copy link
Member Author

The fix is reverted by ballerina-platform/module-ballerina-auth#92.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment