Page MenuHomePhabricator

OAuth uses various magic numbers
Open, Needs TriagePublic

Description

P292277000000Y is used in ClientEntity. No idea what it means, minimal to no documentation

A little more information is found in AuthorizationProvider...

	private function parseExpiration( $expiration ) {
		if ( $expiration === false || $expiration === 'infinity' ) {
			// Effectively non-expiring tokens
			$expiration = 'P292277000000Y';
		}

		return $expiration;
	}

But why is P292277000000Y effectively "non-expiring"/infinite?

More in AuthorizationProviderTest..

	public function provideExpirationInterval() {
		return [
			[ 'P30D', 2592000 ],
			[ false, 9223371259704000000 ],
			[ 'infinity', 9223371259704000000 ],
		];
	}

2592000 is 60*60*24*30... Fine. The other two? no idea...

PT1M and PT1H are also used... Presumably 1H and 1M?

A bit of digging shows it's https://en.wikipedia.org/wiki/ISO_8601#Durations based on https://www.php.net/manual/en/dateinterval.construct.php#112675

In AccessTokenRepository

		if ( $expiry > 9223371197536780800 ) {
			$expiry = 'infinity';
		}

Why does that mean infinity?

Event Timeline

P292277000000Y seems to be close to the equivalent of Year 2038 problem but for 64 bit systems.

9223371259704000000/31536000 = 292471184034.2466, so roughly the same as above. Where 31536000 is number of seconds in 365 days.

9223371259704000000/31557600 = 292270998418.8912, which is closer. (by average number of seconds in one year now). I wonder how to get the original number though (consider leap seconds? xD)

Though 1000 years does not look as fancy as the number over 10 times greater than the age of the universe :)