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

Align stdlib annotations with spec #74

Closed
KRVPerera opened this issue Jun 16, 2020 · 0 comments · Fixed by ballerina-platform/module-ballerina-http#155
Closed

Align stdlib annotations with spec #74

KRVPerera opened this issue Jun 16, 2020 · 0 comments · Fixed by ballerina-platform/module-ballerina-http#155
Assignees
Labels
Area/Security Issues related to stdlib security module/auth Type/Task Verson/SwanLakeDump All issues planned for Swan Lake GA release

Comments

@KRVPerera
Copy link

Description:
Some of the annotation values used in stdlib has complex objects. These objects change their states at runtime. This makes impossible to make annotation value to be aligned with a subtype of the one of true, map<anydata|readonly>, map<anydata|readonly>[].

Spec: https://ballerina.io/spec/lang/2020R1/#section_9.1

The type-descriptor specifies the type of the annotation tag. The type must be a subtype of one of the following three types: true, map, map[]. If the type-descriptor is omitted, then the type is true.

Steps to reproduce:

Examples

OutboundOAuth2Provider

OutboundOAuth2Provider has OutboundOAuth2CacheEntry. This entry gets updated in runtime.

See: https://github.com/ballerina-platform/ballerina-lang/blob/d12f10e71a3462bde5d0e632c590fb00cd7b45e6/stdlib/oauth2/src/main/ballerina/src/oauth2/outbound_oauth2_provider.bal#L677

public type OutboundOAuth2Provider object {

    *auth:OutboundAuthProvider;

    GrantTypeConfig? oauth2ProviderConfig;
    OutboundOAuth2CacheEntry oauth2CacheEntry;

How does it become an annotation value

OutboundOAuth2Provider type includes OutboundAuthProvider abstract object which in turn included in HTTP configuration annotation.

public type HttpServiceConfig record {|
    string host = "b7a.default";
    string basePath = "";
    CompressionConfig compression = {};
    Chunking chunking = CHUNKING_AUTO;
    CorsConfig cors = {};
    Versioning versioning = {};
    ServiceAuth auth?;
|};

public type ServiceAuth record {|
    boolean enabled = true;
    InboundAuthHandlers authHandlers?;
    Scopes scopes?;
|};

public type InboundAuthHandlers InboundAuthHandler[]|InboundAuthHandler[][];
public type InboundAuthHandler abstract object {
    public function canProcess(Request req) returns boolean;
    public function process(Request req) returns boolean|AuthenticationError;
};

Auth handlers have auth providers:

public type BearerAuthHandler object {
    *InboundAuthHandler;
    *OutboundAuthHandler;
    auth:InboundAuthProvider|auth:OutboundAuthProvider authProvider;

InboundJwtAuthProvider

This has cache:Cache jwtCache.

public type InboundJwtAuthProvider object {

    *auth:InboundAuthProvider;

    JwtValidatorConfig jwtValidatorConfig;
public type JwtValidatorConfig record {|
    string issuer?;
    string|string[] audience?;
    int clockSkewInSeconds = 0;
    JwtTrustStoreConfig trustStoreConfig?;
    JwksConfig jwksConfig?;
    cache:Cache jwtCache = new;
|};

Many objects that include InboundAuthHandler has these complex scenarios.

Related Issues (optional):
ballerina-platform/ballerina-lang#15533

Suggested Labels (optional):
Area/Language Area/StandardLibs Type/SpecDeviation

@KRVPerera KRVPerera changed the title Align stdlib annotation with spec deviations and enable readonly object checks for annotation value Align stdlib annotation with spec deviations Jun 17, 2020
@KRVPerera KRVPerera changed the title Align stdlib annotation with spec deviations Align stdlib annotations with spec Jun 17, 2020
@ldclakmal ldclakmal transferred this issue from ballerina-platform/ballerina-lang Oct 23, 2020
@ldclakmal ldclakmal self-assigned this Oct 31, 2020
@ldclakmal ldclakmal added the Verson/SwanLakeDump All issues planned for Swan Lake GA release label Dec 9, 2020
@ldclakmal ldclakmal added this to the Swan Lake - Alpha milestone Dec 9, 2020
@ldclakmal ldclakmal added the Area/Security Issues related to stdlib security label Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Security Issues related to stdlib security module/auth Type/Task Verson/SwanLakeDump All issues planned for Swan Lake GA release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants