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

KeystoneTokenProvider is not checking for token expiration. #129

Open
mhshams opened this issue Jan 31, 2014 · 3 comments
Open

KeystoneTokenProvider is not checking for token expiration. #129

mhshams opened this issue Jan 31, 2014 · 3 comments

Comments

@mhshams
Copy link

mhshams commented Jan 31, 2014

Each token has an expire date, so token provider must check if the current token is expired or not.

this code in KeystoneTokenProvider:

public Access getAccessByTenant(String tenantName) {
        Access access = hashTenantAccess.get(tenantName);
        if (access == null) {  
            //code omitted. (request for new token)
        }
        return access;
}

must be something like:

public Access getAccessByTenant(String tenantName) {
        Access access = hashTenantAccess.get(tenantName);
        if (access == null  || Calendar.getInstance().after(access.getToken().getExpires())) {  
                       //code omitted. (request for new token)
        }
        return access;
}
@hossbert
Copy link

Did you manage to figure this out? It would nice to get a sample on how to handle tokens.

@mhshams
Copy link
Author

mhshams commented May 31, 2014

@hossbert The second code fragment, in the issue, is the sample you are looking for. basically, in addition to check against null values, we need to check the token expiration too:

public Access getAccessByTenant(String tenantName) {
        Access access = hashTenantAccess.get(tenantName);
        if (access == null  || Calendar.getInstance().after(access.getToken().getExpires())) {  
                       //code omitted. (request for new token)
        }
        return access;
}

@hossbert
Copy link

Any chance of this getting merged into the main codebase?
On 31 May 2014 10:48, "Mohammad Shamsi" [email protected] wrote:

@hossbert https://github.com/hossbert The second code fragment, in the
issue, is the sample you are looking for. basically, in addition to check
against null values, we need to check the token expiration too:

public Access getAccessByTenant(String tenantName) {
Access access = hashTenantAccess.get(tenantName);
if (access == null || Calendar.getInstance().after(access.getToken().getExpires())) {
//code omitted. (request for new token)
}
return access;
}


Reply to this email directly or view it on GitHub
#129 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants