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

558 access token for private repositories #1136

Merged
merged 36 commits into from
Jun 10, 2015

Conversation

eugenk
Copy link
Member

@eugenk eugenk commented Dec 5, 2014

This shall fix #558. As soon as hets (spechub/Hets#1422) can handle it completely, this should work. Now, it is working for non-owl files whose file type can be detected by hets' magic.

After merging, don't forget to put this line into the crontab for the expired tokens to be deleted daily:

0 0  * * *  ~/current/script/rails runner 'AccessTokenDeletionWorker.new.perform'

@@ -1,7 +1,7 @@
class Ability
include CanCan::Ability

def initialize(user)
def initialize(user, access_token)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/CyclomaticComplexity: Cyclomatic complexity for initialize is too high. [14/6]
Metrics/MethodLength: Method has too many lines. [102/10]
Metrics/PerceivedComplexity: Perceived complexity for initialize is too high. [17/7]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can ignore this because the ability file is a special case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

@eugenk eugenk force-pushed the 558-access_token_for_private_repositories branch 2 times, most recently from 19a0376 to 23c5ed5 Compare December 5, 2014 10:47
a
end

protected

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAccessModifier: Useless protected access modifier.

@eugenk eugenk force-pushed the 558-access_token_for_private_repositories branch 2 times, most recently from b5796fe to fbac705 Compare December 5, 2014 10:57
Time.now.strftime('%Y-%m-%d-%H-%M-%S-%6N')
].join('|')
AccessToken.new(
{ repository: repository,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/SpaceInsideHashLiteralBraces: Space inside { detected.

@eugenk eugenk force-pushed the 558-access_token_for_private_repositories branch from fbac705 to a60ebc7 Compare December 5, 2014 10:58
@0robustus1
Copy link
Contributor

Why do we use/are we supposed to use the crontab? Why not work directly with sidekiq (e.g. by using a after_create callback to execute the job in x days/hours)?

@eugenk
Copy link
Member Author

eugenk commented Dec 5, 2014

Good point. Is there a sidekiq feature for waiting before performing a task?

By the way, this should actually be done by sidetiq, but somehow sidetiq depends on cron in our setup. I had a private rails4 project where sidetiq did work without cron, but I can't tell why ontohub doesn't.

@0robustus1
Copy link
Contributor

I don't know either why we have such problems with sidetiq, maybe we should investigate that. With regard to the 'waiting': Take a look at the TimeoutWorker, it is using this feature.

:kind => resource.entities.groups_by_kind.first.kind)
if resource.distributed?
redirect_to repository_ontology_children_path(parent, resource,
params_to_pass_on_redirect.merge(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not break the line after the opening parentheses of a method-call.

@eugenk eugenk force-pushed the 558-access_token_for_private_repositories branch from 4853307 to a5046cf Compare June 2, 2015 15:02
@eugenk eugenk removed the in progress label Jun 2, 2015
@eugenk
Copy link
Member Author

eugenk commented Jun 2, 2015

This is now fully adjusted to the changes of interfacing with Hets. It is open for review again.

@eugenk
Copy link
Member Author

eugenk commented Jun 2, 2015

Oh and I rebased this branch on staging. In this process, the Hets::Options related commits were skipped (not needed any more, replaced by the new HetsOptions/ProveOptions).
Those skipped commits were the only ones with conflicts. The staging version has removed all the Hets-CLI related code and the Hets::Options related code from this branch changed those removed lines (and added - now useless - lines in between).

The first new commit is:
Move class methods to the top. f38207c


def params_to_pass_on_redirect
new_params = {}
%i(access-token).each { |key| new_params[key] = params[key] if params[key] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using select?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. select is better :D

@@ -4,6 +4,24 @@ module Repository::Access
OPTIONS = %w[public_r public_rw private_r private_rw]
DEFAULT_OPTION = OPTIONS[0]

def self.as_read_only(access)
access.split('_').first + '_r'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about using a limit to split (e.g. ...split('_', 2)) so optimizations can kick in? I know it's probably just a short string, but why not ;)

@0robustus1
Copy link
Contributor

👍

eugenk added a commit that referenced this pull request Jun 10, 2015
…positories

558 access token for private repositories
@eugenk eugenk merged commit 09bbd1c into staging Jun 10, 2015
@eugenk eugenk deleted the 558-access_token_for_private_repositories branch June 10, 2015 16:12
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 3364a2a on 558-access_token_for_private_repositories into * on staging*.

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

Successfully merging this pull request may close these issues.

Problem with private repositores - download of imported files leads to 403
4 participants